2021-09-12 12:35:27 +00:00
|
|
|
-- Tags: distributed
|
|
|
|
|
2019-09-23 16:18:19 +00:00
|
|
|
-- https://github.com/ClickHouse/ClickHouse/issues/1059
|
2017-10-12 21:28:24 +00:00
|
|
|
|
2023-11-01 14:09:39 +00:00
|
|
|
SET distributed_foreground_insert = 1;
|
2021-02-10 18:09:13 +00:00
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
DROP TABLE IF EXISTS union1;
|
|
|
|
DROP TABLE IF EXISTS union2;
|
|
|
|
DROP TABLE IF EXISTS union3;
|
2017-10-12 21:28:24 +00:00
|
|
|
|
2022-06-23 08:37:52 +00:00
|
|
|
set allow_deprecated_syntax_for_merge_tree=1;
|
2019-06-07 15:41:24 +00:00
|
|
|
CREATE TABLE union1 ( date Date, a Int32, b Int32, c Int32, d Int32) ENGINE = MergeTree(date, (a, date), 8192);
|
|
|
|
CREATE TABLE union2 ( date Date, a Int32, b Int32, c Int32, d Int32) ENGINE = Distributed(test_shard_localhost, currentDatabase(), 'union1');
|
|
|
|
CREATE TABLE union3 ( date Date, a Int32, b Int32, c Int32, d Int32) ENGINE = Distributed(test_shard_localhost, currentDatabase(), 'union2');
|
2017-10-12 21:28:24 +00:00
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
INSERT INTO union1 VALUES (1, 2, 3, 4, 5);
|
|
|
|
INSERT INTO union1 VALUES (11,12,13,14,15);
|
|
|
|
INSERT INTO union2 VALUES (21,22,23,24,25);
|
|
|
|
INSERT INTO union3 VALUES (31,32,33,34,35);
|
2017-10-12 21:28:24 +00:00
|
|
|
|
2021-04-04 12:07:52 +00:00
|
|
|
select b, sum(c) from ( select a, b, sum(c) as c from union2 where a>1 group by a,b UNION ALL select a, b, sum(c) as c from union2 where b>1 group by a, b order by a, b) as a group by b order by b;
|
|
|
|
select b, sum(c) from ( select a, b, sum(c) as c from union1 where a>1 group by a,b UNION ALL select a, b, sum(c) as c from union2 where b>1 group by a, b order by a, b) as a group by b order by b;
|
|
|
|
select b, sum(c) from ( select a, b, sum(c) as c from union1 where a>1 group by a,b UNION ALL select a, b, sum(c) as c from union1 where b>1 group by a, b order by a, b) as a group by b order by b;
|
|
|
|
select b, sum(c) from ( select a, b, sum(c) as c from union2 where a>1 group by a,b UNION ALL select a, b, sum(c) as c from union3 where b>1 group by a, b order by a, b) as a group by b order by b;
|
2017-10-12 21:28:24 +00:00
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
DROP TABLE union1;
|
|
|
|
DROP TABLE union2;
|
|
|
|
DROP TABLE union3;
|