dbms: Server: Fixed incorrect behavior with the DISTINCT keyword [#METR-14408]

This commit is contained in:
Alexey Arno 2015-05-05 17:02:57 +03:00
parent 218984bb65
commit 8ff005e909
3 changed files with 16 additions and 2 deletions

View File

@ -499,7 +499,7 @@ void InterpreterSelectQuery::executeSingleQuery()
if (second_stage)
{
bool need_second_distinct_pass = true;
bool need_second_distinct_pass = query.distinct;
if (need_aggregate)
{
@ -515,7 +515,7 @@ void InterpreterSelectQuery::executeSingleQuery()
executeExpression(streams, before_order_and_select);
executeDistinct(streams, true, selected_columns);
need_second_distinct_pass = streams.size() > 1;
need_second_distinct_pass = query.distinct && (streams.size() > 1);
}
else if (query.group_by_with_totals && !aggregate_final)
{
@ -548,6 +548,9 @@ void InterpreterSelectQuery::executeSingleQuery()
if (query.limit_length && streams.size() > 1 && !query.distinct)
executePreLimit(streams);
if (need_second_distinct_pass)
union_within_single_query = true;
if (union_within_single_query)
executeUnion(streams);

View File

@ -0,0 +1,10 @@
0
1
2
3
4
5
6
7
8
9

View File

@ -0,0 +1 @@
SELECT DISTINCT number FROM remote('127.0.0.{1,2}', system.numbers) LIMIT 10