diff --git a/dbms/src/Interpreters/InterpreterSelectQuery.cpp b/dbms/src/Interpreters/InterpreterSelectQuery.cpp index 791b15b50a123db74981cf0e9a5eb1cbb09c0e24..8bd7ab4fa100aab0d27eefa31df49293f2a20235 100644 --- a/dbms/src/Interpreters/InterpreterSelectQuery.cpp +++ b/dbms/src/Interpreters/InterpreterSelectQuery.cpp @@ -555,9 +555,7 @@ void InterpreterSelectQuery::executeSingleQuery() { /// Если было более одного источника - то нужно выполнить DISTINCT ещё раз после их слияния. if (need_second_distinct_pass) - { executeDistinct(streams, false, Names()); - } executeLimit(streams); } @@ -922,6 +920,9 @@ void InterpreterSelectQuery::executeDistinct(BlockInputStreams & streams, bool b { stream = new DistinctBlockInputStream(stream, settings.limits, limit_for_distinct, columns); } + + if (streams.size() > 1) + union_within_single_query = true; } } @@ -952,6 +953,7 @@ void InterpreterSelectQuery::executePreLimit(BlockInputStreams & streams) { stream = new LimitBlockInputStream(stream, limit_length + limit_offset, 0); } + if (streams.size() > 1) union_within_single_query = true; }