This commit is contained in:
Alexey Milovidov 2018-08-08 06:09:59 +03:00
parent e0dc0ccaff
commit 207a2b8b3c
3 changed files with 41 additions and 4 deletions

View File

@ -212,7 +212,7 @@ InterpreterSelectQuery::InterpreterSelectQuery(
/// Calculate structure of the result.
{
Pipeline pipeline;
executeImpl(pipeline, input, true);
executeImpl(pipeline, nullptr, true);
result_header = pipeline.firstStream()->getHeader();
}
}
@ -360,9 +360,6 @@ InterpreterSelectQuery::AnalysisResult InterpreterSelectQuery::analyzeExpression
void InterpreterSelectQuery::executeImpl(Pipeline & pipeline, const BlockInputStreamPtr & input, bool dry_run)
{
if (input)
pipeline.streams.push_back(input);
/** Streams of data. When the query is executed in parallel, we have several data streams.
* If there is no GROUP BY, then perform all operations before ORDER BY and LIMIT in parallel, then
* if there is an ORDER BY, then glue the streams using UnionBlockInputStream, and then MergeSortingBlockInputStream,
@ -382,6 +379,9 @@ void InterpreterSelectQuery::executeImpl(Pipeline & pipeline, const BlockInputSt
}
else
{
if (input)
pipeline.streams.push_back(input);
/** Read the data from Storage. from_stage - to what stage the request was completed in Storage. */
QueryProcessingStage::Enum from_stage = executeFetchColumns(pipeline);

View File

@ -0,0 +1,6 @@
stest
---
stest
stest
---
stest

View File

@ -0,0 +1,31 @@
DROP TABLE IF EXISTS test.test;
DROP TABLE IF EXISTS test.mv_bad;
DROP TABLE IF EXISTS test.mv_good;
DROP TABLE IF EXISTS test.mv_group;
CREATE TABLE test.test (x String) ENGINE = Null;
create MATERIALIZED VIEW test.mv_bad (x String)
ENGINE = MergeTree Partition by tuple() order by tuple()
AS SELECT DISTINCT x FROM test.test;
create MATERIALIZED VIEW test.mv_good (x String)
ENGINE = MergeTree Partition by tuple() order by tuple()
AS SELECT x FROM test.test;
create MATERIALIZED VIEW test.mv_group (x String)
ENGINE = MergeTree Partition by tuple() order by tuple()
AS SELECT x FROM test.test group by x;
insert into test.test values ('stest'), ('stest');
select * from test.mv_bad;
SELECT '---';
select * from test.mv_good;
SELECT '---';
select * from test.mv_group;
DROP TABLE test.mv_bad;
DROP TABLE test.mv_good;
DROP TABLE test.mv_group;
DROP TABLE test.test;