Fix 02003_WithMergeableStateAfterAggregationAndLimit_LIMIT_BY_LIMIT_OFFSET

This commit is contained in:
Azat Khuzhin 2021-08-08 10:10:36 +03:00
parent 3be3c503aa
commit f19ff3d61c
2 changed files with 24 additions and 12 deletions

View File

@ -1,16 +1,17 @@
-- { echo } -- { echo }
SELECT * SELECT *
FROM remote('127.{1,2}', view( FROM remote('127.{1,2}', view(
SELECT * SELECT number%20 number
FROM numbers(10) FROM numbers(40)
WHERE (number % 2) = (shardNum() - 1)
), number) ), number)
GROUP BY number GROUP BY number
ORDER BY number ASC ORDER BY number ASC
LIMIT 1 BY number LIMIT 1 BY number
LIMIT 5, 5 LIMIT 5, 5
SETTINGS SETTINGS
optimize_skip_unused_shards = 1, optimize_skip_unused_shards=1,
optimize_distributed_group_by_sharding_key = 1, optimize_distributed_group_by_sharding_key=1,
distributed_push_down_limit=1; distributed_push_down_limit=1;
5 5
6 6
@ -19,8 +20,9 @@ SETTINGS
9 9
SELECT * SELECT *
FROM remote('127.{1,2}', view( FROM remote('127.{1,2}', view(
SELECT * SELECT number%20 number
FROM numbers(10) FROM numbers(40)
WHERE (number % 2) = (shardNum() - 1)
), number) ), number)
GROUP BY number GROUP BY number
ORDER BY number ASC ORDER BY number ASC

View File

@ -1,21 +1,31 @@
-- Here we use a trick with shardNum() to generate unique data on each shard.
-- Since distributed_group_by_no_merge=2 will use WithMergeableStateAfterAggregationAndLimit,
-- which assume that the data on shards is unique
-- (LIMIT BY will be applied only on shards, not on the initiator).
-- To distinguish echoing from the comments above we use SELECT FORMAT Null.
SELECT '' FORMAT Null;
-- { echo } -- { echo }
SELECT * SELECT *
FROM remote('127.{1,2}', view( FROM remote('127.{1,2}', view(
SELECT * SELECT number%20 number
FROM numbers(10) FROM numbers(40)
WHERE (number % 2) = (shardNum() - 1)
), number) ), number)
GROUP BY number GROUP BY number
ORDER BY number ASC ORDER BY number ASC
LIMIT 1 BY number LIMIT 1 BY number
LIMIT 5, 5 LIMIT 5, 5
SETTINGS SETTINGS
optimize_skip_unused_shards = 1, optimize_skip_unused_shards=1,
optimize_distributed_group_by_sharding_key = 1, optimize_distributed_group_by_sharding_key=1,
distributed_push_down_limit=1; distributed_push_down_limit=1;
SELECT * SELECT *
FROM remote('127.{1,2}', view( FROM remote('127.{1,2}', view(
SELECT * SELECT number%20 number
FROM numbers(10) FROM numbers(40)
WHERE (number % 2) = (shardNum() - 1)
), number) ), number)
GROUP BY number GROUP BY number
ORDER BY number ASC ORDER BY number ASC