diff --git a/tests/queries/0_stateless/03273_group_by_in_order_still_used_when_group_by_key_doesnt_match_order_by_key.reference b/tests/queries/0_stateless/03273_group_by_in_order_still_used_when_group_by_key_doesnt_match_order_by_key.reference new file mode 100644 index 00000000000..95dcf3f77b3 --- /dev/null +++ b/tests/queries/0_stateless/03273_group_by_in_order_still_used_when_group_by_key_doesnt_match_order_by_key.reference @@ -0,0 +1,2 @@ +Order: a ASC, b ASC +ReadType: InOrder diff --git a/tests/queries/0_stateless/03273_group_by_in_order_still_used_when_group_by_key_doesnt_match_order_by_key.sql b/tests/queries/0_stateless/03273_group_by_in_order_still_used_when_group_by_key_doesnt_match_order_by_key.sql new file mode 100644 index 00000000000..d4585ea548d --- /dev/null +++ b/tests/queries/0_stateless/03273_group_by_in_order_still_used_when_group_by_key_doesnt_match_order_by_key.sql @@ -0,0 +1,24 @@ +CREATE TABLE test +( + a UInt64, + b UInt64 +) +ENGINE = MergeTree +ORDER BY (a, b); + +INSERT INTO test SELECT number, number FROM numbers_mt(1e6); + +set enable_analyzer = 1; + +SELECT trimBoth(replaceRegexpAll(explain, '__table1.', '')) +FROM +( + EXPLAIN actions = 1 + SELECT count(*) + FROM test + GROUP BY + b, + a + SETTINGS optimize_aggregation_in_order = 1 +) +WHERE explain LIKE '%Order%';