ClickHouse/tests/queries/0_stateless/00584_view_union_all.sql

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
678 B
MySQL
Raw Normal View History

2019-06-03 17:36:27 +00:00
DROP TABLE IF EXISTS Test_00584;
2018-03-01 06:21:15 +00:00
2022-06-23 08:37:52 +00:00
set allow_deprecated_syntax_for_merge_tree=1;
2019-06-03 17:36:27 +00:00
CREATE TABLE Test_00584 (
2018-03-01 06:21:15 +00:00
createdDate Date,
str String,
key Enum8('A' = 0, 'B' = 1, 'ALL' = 2),
a Int64
)
ENGINE = MergeTree(createdDate, str, 8192);
2019-06-03 17:36:27 +00:00
INSERT INTO Test_00584 VALUES ('2000-01-01', 'hello', 'A', 123);
2018-03-01 06:21:15 +00:00
SET max_threads = 1;
CREATE VIEW TestView AS
2018-03-01 06:21:15 +00:00
SELECT str, key, sumIf(a, 0) AS sum
2019-06-03 17:36:27 +00:00
FROM Test_00584
2018-03-01 06:21:15 +00:00
GROUP BY str, key
UNION ALL
SELECT str AS str, CAST('ALL' AS Enum8('A' = 0, 'B' = 1, 'ALL' = 2)) AS key, sumIf(a, 0) AS sum
2019-06-03 17:36:27 +00:00
FROM Test_00584
2018-03-01 06:21:15 +00:00
GROUP BY str;
2019-07-05 14:52:29 +00:00
SELECT * FROM TestView ORDER BY key;
2018-03-01 06:21:15 +00:00
DROP TABLE TestView;
2019-06-03 17:36:27 +00:00
DROP TABLE Test_00584;