diff --git a/tests/queries/0_stateless/01786_group_by_pk_many_streams.reference b/tests/queries/0_stateless/01786_group_by_pk_many_streams.reference new file mode 100644 index 00000000000..b8809e746a5 --- /dev/null +++ b/tests/queries/0_stateless/01786_group_by_pk_many_streams.reference @@ -0,0 +1,11 @@ +94950 +84950 +74950 +64950 +54950 +======= +94950 +84950 +74950 +64950 +54950 diff --git a/tests/queries/0_stateless/01786_group_by_pk_many_streams.sql b/tests/queries/0_stateless/01786_group_by_pk_many_streams.sql new file mode 100644 index 00000000000..e555aa4d6e6 --- /dev/null +++ b/tests/queries/0_stateless/01786_group_by_pk_many_streams.sql @@ -0,0 +1,16 @@ +DROP TABLE IF EXISTS group_by_pk; + +CREATE TABLE group_by_pk (k UInt64, v UInt64) +ENGINE = MergeTree ORDER BY k PARTITION BY v % 50; + +INSERT INTO group_by_pk SELECT number / 100, number FROM numbers(1000); + +SELECT sum(v) AS s FROM group_by_pk GROUP BY k ORDER BY s DESC LIMIT 5 +SETTINGS optimize_aggregation_in_order = 1, max_block_size = 1; + +SELECT '======='; + +SELECT sum(v) AS s FROM group_by_pk GROUP BY k ORDER BY s DESC LIMIT 5 +SETTINGS optimize_aggregation_in_order = 0, max_block_size = 1; + +DROP TABLE IF EXISTS group_by_pk;