From 848e4a0541630aef09cd7fb4926c89b7bdd0c060 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Mon, 20 Apr 2020 11:15:43 +0300 Subject: [PATCH] Added a test for #2219 --- ..._aggregate_function_JustStranger.reference | 1 + ...ery_in_aggregate_function_JustStranger.sql | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 tests/queries/0_stateless/01253_subquery_in_aggregate_function_JustStranger.reference create mode 100644 tests/queries/0_stateless/01253_subquery_in_aggregate_function_JustStranger.sql diff --git a/tests/queries/0_stateless/01253_subquery_in_aggregate_function_JustStranger.reference b/tests/queries/0_stateless/01253_subquery_in_aggregate_function_JustStranger.reference new file mode 100644 index 00000000000..72c3262a309 --- /dev/null +++ b/tests/queries/0_stateless/01253_subquery_in_aggregate_function_JustStranger.reference @@ -0,0 +1 @@ +Hello 1 diff --git a/tests/queries/0_stateless/01253_subquery_in_aggregate_function_JustStranger.sql b/tests/queries/0_stateless/01253_subquery_in_aggregate_function_JustStranger.sql new file mode 100644 index 00000000000..9659db7973d --- /dev/null +++ b/tests/queries/0_stateless/01253_subquery_in_aggregate_function_JustStranger.sql @@ -0,0 +1,32 @@ +DROP TABLE IF EXISTS test_table; +DROP TABLE IF EXISTS test_table_sharded; + +create table + test_table_sharded( + date Date, + text String, + hash UInt64 + ) +engine=MergeTree(date, (hash, date), 8192); + +create table test_table as test_table_sharded +engine=Distributed(test_cluster_two_shards, currentDatabase(), test_table_sharded, hash); + +SET distributed_product_mode = 'local'; +SET insert_distributed_sync = 1; + +INSERT INTO test_table VALUES ('2020-04-20', 'Hello', 123); + +SELECT + text, + uniqExactIf(hash, hash IN ( + SELECT DISTINCT + hash + FROM test_table AS t1 + )) as counter +FROM test_table AS t2 +GROUP BY text +ORDER BY counter, text; + +DROP TABLE test_table; +DROP TABLE test_table_sharded;