Merge branch 'dist-agg-issue' of https://github.com/chengxianglibra/ClickHouse into chengxianglibra-dist-agg-issue

This commit is contained in:
Nikolai Kochetov 2020-11-26 11:35:47 +03:00
commit 42399e8866
3 changed files with 34 additions and 3 deletions

View File

@ -9,9 +9,13 @@ namespace DB
static bool checkColumnsAlreadyDistinct(const Names & columns, const NameSet & distinct_names)
{
bool columns_already_distinct = true;
for (const auto & name : columns)
if (distinct_names.count(name) == 0)
columns_already_distinct = false;
if (columns.size() != distinct_names.size()) {
columns_already_distinct = false;
} else {
for (const auto & name : columns)
if (distinct_names.count(name) == 0)
columns_already_distinct = false;
}
return columns_already_distinct;
}

View File

@ -0,0 +1,9 @@
a 0
a 1
b 0
---
0
1
---
0
1

View File

@ -0,0 +1,18 @@
DROP TABLE IF EXISTS t;
DROP TABLE IF EXISTS d;
CREATE TABLE t (a String, b Int) ENGINE = TinyLog;
INSERT INTO t VALUES ('a', 0), ('a', 1), ('b', 0);
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);
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);
DROP TABLE d;
DROP TABLE t;