mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
dbms: Server: Fixed incorrect behavior with the DISTINCT keyword [#METR-14408]
This commit is contained in:
parent
218984bb65
commit
8ff005e909
@ -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);
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
@ -0,0 +1 @@
|
||||
SELECT DISTINCT number FROM remote('127.0.0.{1,2}', system.numbers) LIMIT 10
|
Loading…
Reference in New Issue
Block a user