From 0e925ff7ad6370b64f449097919bd8c083e43cb5 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sun, 22 Mar 2020 20:47:01 +0300 Subject: [PATCH] Cover DISTINCT for Distributed with one shard (test from #9046) v2: cover case when getQueryProcessingStage() returns Complete when it should not (pointed by @alexey-milovidov in https://github.com/ClickHouse/ClickHouse/pull/9808#issuecomment-602291996) --- ...mize_skip_unused_shards_DISTINCT.reference | 8 ++++++++ ...3_optimize_skip_unused_shards_DISTINCT.sql | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 dbms/tests/queries/0_stateless/01213_optimize_skip_unused_shards_DISTINCT.reference create mode 100644 dbms/tests/queries/0_stateless/01213_optimize_skip_unused_shards_DISTINCT.sql diff --git a/dbms/tests/queries/0_stateless/01213_optimize_skip_unused_shards_DISTINCT.reference b/dbms/tests/queries/0_stateless/01213_optimize_skip_unused_shards_DISTINCT.reference new file mode 100644 index 00000000000..4ade9cd9c5d --- /dev/null +++ b/dbms/tests/queries/0_stateless/01213_optimize_skip_unused_shards_DISTINCT.reference @@ -0,0 +1,8 @@ +distributed_group_by_no_merge +1 +1 +optimize_skip_unused_shards +1 +optimize_skip_unused_shards lack of WHERE +0 +1 diff --git a/dbms/tests/queries/0_stateless/01213_optimize_skip_unused_shards_DISTINCT.sql b/dbms/tests/queries/0_stateless/01213_optimize_skip_unused_shards_DISTINCT.sql new file mode 100644 index 00000000000..5b45bea9046 --- /dev/null +++ b/dbms/tests/queries/0_stateless/01213_optimize_skip_unused_shards_DISTINCT.sql @@ -0,0 +1,19 @@ +CREATE TABLE IF NOT EXISTS local_01213 (id Int) ENGINE = MergeTree ORDER BY tuple(); +CREATE TABLE IF NOT EXISTS dist_01213 AS local_01213 ENGINE = Distributed(test_cluster_two_shards_localhost, currentDatabase(), local_01213, id); + +-- at least two parts +INSERT INTO local_01213 SELECT toString(number) FROM numbers(2); +INSERT INTO local_01213 SELECT toString(number) FROM numbers(2); + +-- check that without merge we will have two rows +SELECT 'distributed_group_by_no_merge'; +SELECT DISTINCT id FROM dist_01213 WHERE id = 1 SETTINGS distributed_group_by_no_merge=1; +-- check that with merge there will be only one +SELECT 'optimize_skip_unused_shards'; +SELECT DISTINCT id FROM dist_01213 WHERE id = 1 SETTINGS optimize_skip_unused_shards=1; +-- check that querying all shards is ok +SELECT 'optimize_skip_unused_shards lack of WHERE'; +SELECT DISTINCT id FROM dist_01213 SETTINGS optimize_skip_unused_shards=1; + +DROP TABLE local_01213; +DROP TABLE dist_01213;