mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 02:21:59 +00:00
Add tests
This commit is contained in:
parent
cc5456c649
commit
603a52caa0
28
tests/queries/0_stateless/02968_projection_merge.reference
Normal file
28
tests/queries/0_stateless/02968_projection_merge.reference
Normal file
@ -0,0 +1,28 @@
|
||||
ReplacingMergeTree
|
||||
0 2
|
||||
1 2
|
||||
2 2
|
||||
0 2
|
||||
1 2
|
||||
2 2
|
||||
CollapsingMergeTree
|
||||
0 2
|
||||
1 2
|
||||
2 2
|
||||
0 2
|
||||
1 2
|
||||
2 2
|
||||
VersionedCollapsingMergeTree
|
||||
0 2
|
||||
1 2
|
||||
2 2
|
||||
0 2
|
||||
1 2
|
||||
2 2
|
||||
DEDUPLICATE ON MergeTree
|
||||
0 1
|
||||
1 1
|
||||
2 1
|
||||
0 1
|
||||
1 1
|
||||
2 1
|
112
tests/queries/0_stateless/02968_projection_merge.sql
Normal file
112
tests/queries/0_stateless/02968_projection_merge.sql
Normal file
@ -0,0 +1,112 @@
|
||||
SELECT 'ReplacingMergeTree';
|
||||
DROP TABLE IF EXISTS tp;
|
||||
CREATE TABLE tp
|
||||
(
|
||||
`type` Int32,
|
||||
`eventcnt` UInt64,
|
||||
PROJECTION p
|
||||
(
|
||||
SELECT type,sum(eventcnt)
|
||||
GROUP BY type
|
||||
)
|
||||
)
|
||||
ENGINE = ReplacingMergeTree
|
||||
ORDER BY type;
|
||||
|
||||
INSERT INTO tp SELECT number%3, 1 FROM numbers(3);
|
||||
INSERT INTO tp SELECT number%3, 2 FROM numbers(3);
|
||||
|
||||
OPTIMIZE TABLE tp FINAL;
|
||||
|
||||
SELECT type,sum(eventcnt) FROM tp GROUP BY type ORDER BY type
|
||||
SETTINGS allow_experimental_projection_optimization = 0, force_optimize_projection = 0;
|
||||
|
||||
SELECT type,sum(eventcnt) FROM tp GROUP BY type ORDER BY type
|
||||
SETTINGS allow_experimental_projection_optimization = 1, force_optimize_projection = 1;
|
||||
|
||||
|
||||
SELECT 'CollapsingMergeTree';
|
||||
DROP TABLE IF EXISTS tp;
|
||||
CREATE TABLE tp
|
||||
(
|
||||
`type` Int32,
|
||||
`eventcnt` UInt64,
|
||||
`sign` Int8,
|
||||
PROJECTION p
|
||||
(
|
||||
SELECT type,sum(eventcnt)
|
||||
GROUP BY type
|
||||
)
|
||||
)
|
||||
ENGINE = CollapsingMergeTree(sign)
|
||||
ORDER BY type;
|
||||
|
||||
INSERT INTO tp SELECT number % 3, 1, 1 FROM numbers(3);
|
||||
INSERT INTO tp SELECT number % 3, 1, -1 FROM numbers(3);
|
||||
INSERT INTO tp SELECT number % 3, 2, 1 FROM numbers(3);
|
||||
|
||||
OPTIMIZE TABLE tp FINAL;
|
||||
|
||||
SELECT type,sum(eventcnt) FROM tp GROUP BY type ORDER BY type
|
||||
SETTINGS allow_experimental_projection_optimization = 0, force_optimize_projection = 0;
|
||||
|
||||
SELECT type,sum(eventcnt) FROM tp GROUP BY type ORDER BY type
|
||||
SETTINGS allow_experimental_projection_optimization = 1, force_optimize_projection = 1;
|
||||
|
||||
-- Actually we don't need to test all 3 engines Replacing/Collapsing/VersionedCollapsing,
|
||||
-- Because they share the same logic of 'reduce number of rows during merges'
|
||||
SELECT 'VersionedCollapsingMergeTree';
|
||||
DROP TABLE IF EXISTS tp;
|
||||
CREATE TABLE tp
|
||||
(
|
||||
`type` Int32,
|
||||
`eventcnt` UInt64,
|
||||
`sign` Int8,
|
||||
`version` UInt8,
|
||||
PROJECTION p
|
||||
(
|
||||
SELECT type,sum(eventcnt)
|
||||
GROUP BY type
|
||||
)
|
||||
)
|
||||
ENGINE = VersionedCollapsingMergeTree(sign,version)
|
||||
ORDER BY type;
|
||||
|
||||
INSERT INTO tp SELECT number % 3, 1, -1, 0 FROM numbers(3);
|
||||
INSERT INTO tp SELECT number % 3, 2, 1, 1 FROM numbers(3);
|
||||
INSERT INTO tp SELECT number % 3, 1, 1, 0 FROM numbers(3);
|
||||
|
||||
OPTIMIZE TABLE tp FINAL;
|
||||
|
||||
SELECT type,sum(eventcnt) FROM tp GROUP BY type ORDER BY type
|
||||
SETTINGS allow_experimental_projection_optimization = 0, force_optimize_projection = 0;
|
||||
|
||||
SELECT type,sum(eventcnt) FROM tp GROUP BY type ORDER BY type
|
||||
SETTINGS allow_experimental_projection_optimization = 1, force_optimize_projection = 1;
|
||||
|
||||
SELECT 'DEDUPLICATE ON MergeTree';
|
||||
DROP TABLE IF EXISTS tp;
|
||||
CREATE TABLE tp
|
||||
(
|
||||
`type` Int32,
|
||||
`eventcnt` UInt64,
|
||||
PROJECTION p
|
||||
(
|
||||
SELECT type,sum(eventcnt)
|
||||
GROUP BY type
|
||||
)
|
||||
)
|
||||
ENGINE = MergeTree
|
||||
ORDER BY type;
|
||||
|
||||
INSERT INTO tp SELECT number % 3, 1 FROM numbers(3);
|
||||
INSERT INTO tp SELECT number % 3, 2 FROM numbers(3);
|
||||
|
||||
OPTIMIZE TABLE tp FINAL DEDUPLICATE BY type;
|
||||
|
||||
SELECT type,sum(eventcnt) FROM tp GROUP BY type ORDER BY type
|
||||
SETTINGS allow_experimental_projection_optimization = 0, force_optimize_projection = 0;
|
||||
|
||||
SELECT type,sum(eventcnt) FROM tp GROUP BY type ORDER BY type
|
||||
SETTINGS allow_experimental_projection_optimization = 1, force_optimize_projection = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user