diff --git a/tests/queries/0_stateless/01582_distinct_optimization.reference b/tests/queries/0_stateless/01582_distinct_optimization.reference new file mode 100644 index 00000000000..4763dc095d6 --- /dev/null +++ b/tests/queries/0_stateless/01582_distinct_optimization.reference @@ -0,0 +1,4 @@ +---- +DistinctTransform +DistinctTransform +---- diff --git a/tests/queries/0_stateless/01582_distinct_optimization.sh b/tests/queries/0_stateless/01582_distinct_optimization.sh new file mode 100755 index 00000000000..f1ca484befb --- /dev/null +++ b/tests/queries/0_stateless/01582_distinct_optimization.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. "$CURDIR"/../shell_config.sh + + +$CLICKHOUSE_CLIENT --query="CREATE TABLE test_local (a String, b Int) Engine=TinyLog" +$CLICKHOUSE_CLIENT --query="INSERT INTO test_local VALUES('a', 0), ('a', 1), ('b', 0)" +echo "----" +$CLICKHOUSE_CLIENT --query="EXPLAIN PIPELINE SELECT DISTINCT b FROM (SELECT b FROM remote('127.0.0.{1,2}', currentDatabase(), test_local) GROUP BY a, b)" | grep -o "DistinctTransform" || true +echo "----" +$CLICKHOUSE_CLIENT --query="EXPLAIN PIPELINE SELECT DISTINCT a, b, b + 1 FROM (SELECT a, b FROM remote('127.0.0.{1,2}', currentDatabase(), test_local) GROUP BY a, b)" | grep -o "DistinctTransform" || true diff --git a/tests/queries/0_stateless/01582_distinct_subquery_groupby.sql b/tests/queries/0_stateless/01582_distinct_subquery_groupby.sql index 08aad8421c0..7251dc4286b 100644 --- a/tests/queries/0_stateless/01582_distinct_subquery_groupby.sql +++ b/tests/queries/0_stateless/01582_distinct_subquery_groupby.sql @@ -7,12 +7,12 @@ SELECT * FROM t; SELECT '---'; CREATE TABLE d (a String, b Int) ENGINE = Distributed(test_shard_localhost, currentDatabase(), t); -SELECT DISTINCT b FROM (SELECT a, b FROM d GROUP BY a, b); +SELECT DISTINCT b FROM (SELECT a, b FROM d GROUP BY a, b) order by b; DROP TABLE d; SELECT '---'; CREATE TABLE d (a String, b Int) ENGINE = Distributed(test_cluster_two_shards_localhost, currentDatabase(), t); -SELECT DISTINCT b FROM (SELECT a, b FROM d GROUP BY a, b); +SELECT DISTINCT b FROM (SELECT a, b FROM d GROUP BY a, b) order by b; DROP TABLE d; DROP TABLE t;