mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 13:02:00 +00:00
Fix optimize_distributed_group_by_sharding_key for query with OFFSET only (#16996)
* Fix optimize_distributed_group_by_sharding_key for query with OFFSET only * Fix 01244_optimize_distributed_group_by_sharding_key flakiness
This commit is contained in:
parent
9b72323594
commit
5365718f01
@ -315,7 +315,8 @@ std::optional<QueryProcessingStage::Enum> getOptimizedQueryProcessingStage(const
|
||||
|
||||
// LIMIT BY
|
||||
// LIMIT
|
||||
if (select.limitBy() || select.limitLength())
|
||||
// OFFSET
|
||||
if (select.limitBy() || select.limitLength() || select.limitOffset())
|
||||
return QueryProcessingStage::WithMergeableStateAfterAggregation;
|
||||
|
||||
// Only simple SELECT FROM GROUP BY sharding_key can use Complete state.
|
||||
|
@ -57,6 +57,10 @@ LIMIT
|
||||
1 0
|
||||
LIMIT OFFSET
|
||||
1 1
|
||||
OFFSET
|
||||
1 1
|
||||
1 0
|
||||
1 1
|
||||
WHERE LIMIT OFFSET
|
||||
1 1
|
||||
LIMIT BY 1
|
||||
|
@ -16,6 +16,7 @@ create table dist_01247 as data_01247 engine=Distributed(test_cluster_two_shards
|
||||
-- (and this is how we ensure that this optimization will work)
|
||||
|
||||
set max_distributed_connections=1;
|
||||
set prefer_localhost_replica=0;
|
||||
|
||||
select '-';
|
||||
select * from dist_01247;
|
||||
@ -63,6 +64,8 @@ select 'LIMIT';
|
||||
select count(), * from dist_01247 group by number limit 1;
|
||||
select 'LIMIT OFFSET';
|
||||
select count(), * from dist_01247 group by number limit 1 offset 1;
|
||||
select 'OFFSET';
|
||||
select count(), * from dist_01247 group by number offset 1;
|
||||
-- this will emulate different data on for different shards
|
||||
select 'WHERE LIMIT OFFSET';
|
||||
select count(), * from dist_01247 where number = _shard_num-1 group by number limit 1 offset 1;
|
||||
|
Loading…
Reference in New Issue
Block a user