mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-10-19 23:10:50 +00:00
74 lines
3.3 KiB
SQL
74 lines
3.3 KiB
SQL
----- Group of very similar simple tests ------
|
|
DROP TABLE IF EXISTS test.zero_rows_per_granule;
|
|
|
|
CREATE TABLE test.zero_rows_per_granule (
|
|
p Date,
|
|
k UInt64,
|
|
v1 UInt64,
|
|
v2 Int64,
|
|
Sign Int8
|
|
) ENGINE CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(p) ORDER BY k
|
|
SETTINGS index_granularity_bytes=20,
|
|
enable_vertical_merge_algorithm=1,
|
|
vertical_merge_algorithm_min_rows_to_activate=0,
|
|
vertical_merge_algorithm_min_columns_to_activate=0;
|
|
|
|
INSERT INTO test.zero_rows_per_granule (p, k, v1, v2, Sign) VALUES ('2018-05-15', 1, 1000, 2000, 1), ('2018-05-16', 2, 3000, 4000, 1), ('2018-05-17', 3, 5000, 6000, 1), ('2018-05-18', 4, 7000, 8000, 1);
|
|
|
|
SELECT COUNT(*) FROM test.zero_rows_per_granule;
|
|
|
|
SELECT distinct(marks) from system.parts WHERE table = 'zero_rows_per_granule' and database='test' and active=1;
|
|
|
|
INSERT INTO test.zero_rows_per_granule (p, k, v1, v2, Sign) VALUES ('2018-05-15', 5, 1000, 2000, 1), ('2018-05-16', 6, 3000, 4000, 1), ('2018-05-17', 7, 5000, 6000, 1), ('2018-05-19', 8, 7000, 8000, 1);
|
|
|
|
OPTIMIZE TABLE test.zero_rows_per_granule FINAL;
|
|
|
|
SELECT COUNT(*) FROM test.zero_rows_per_granule FINAL;
|
|
|
|
SELECT sum(marks) from system.parts WHERE table = 'zero_rows_per_granule' and database='test' and active=1;
|
|
|
|
DROP TABLE IF EXISTS test.zero_rows_per_granule;
|
|
|
|
SELECT '-----';
|
|
DROP TABLE IF EXISTS test.four_rows_per_granule;
|
|
|
|
CREATE TABLE test.four_rows_per_granule (
|
|
p Date,
|
|
k UInt64,
|
|
v1 UInt64,
|
|
v2 Int64,
|
|
Sign Int8
|
|
) ENGINE CollapsingMergeTree(Sign) PARTITION BY toYYYYMM(p) ORDER BY k
|
|
SETTINGS index_granularity_bytes=110,
|
|
enable_vertical_merge_algorithm=1,
|
|
vertical_merge_algorithm_min_rows_to_activate=0,
|
|
vertical_merge_algorithm_min_columns_to_activate=0;
|
|
|
|
INSERT INTO test.four_rows_per_granule (p, k, v1, v2, Sign) VALUES ('2018-05-15', 1, 1000, 2000, 1), ('2018-05-16', 2, 3000, 4000, 1), ('2018-05-17', 3, 5000, 6000, 1), ('2018-05-18', 4, 7000, 8000, 1);
|
|
|
|
SELECT COUNT(*) FROM test.four_rows_per_granule;
|
|
|
|
SELECT distinct(marks) from system.parts WHERE table = 'four_rows_per_granule' and database='test' and active=1;
|
|
|
|
INSERT INTO test.four_rows_per_granule (p, k, v1, v2, Sign) VALUES ('2018-05-15', 1, 1000, 2000, -1), ('2018-05-16', 2, 3000, 4000, -1), ('2018-05-17', 3, 5000, 6000, -1), ('2018-05-18', 4, 7000, 8000, -1);
|
|
|
|
OPTIMIZE TABLE test.four_rows_per_granule FINAL;
|
|
|
|
SELECT COUNT(*) FROM test.four_rows_per_granule;
|
|
|
|
SELECT distinct(marks) from system.parts WHERE table = 'four_rows_per_granule' and database='test' and active=1;
|
|
|
|
INSERT INTO test.four_rows_per_granule (p, k, v1, v2, Sign) VALUES ('2018-05-15', 1, 1000, 2000, 1), ('2018-05-16', 2, 3000, 4000, 1), ('2018-05-17', 3, 5000, 6000, 1), ('2018-05-18', 4, 7000, 8000, 1);
|
|
|
|
INSERT INTO test.four_rows_per_granule (p, k, v1, v2, Sign) VALUES ('2018-05-15', 5, 1000, 2000, 1), ('2018-05-16', 6, 3000, 4000, 1), ('2018-05-17', 7, 5000, 6000, 1), ('2018-05-18', 8, 7000, 8000, 1);
|
|
|
|
INSERT INTO test.four_rows_per_granule (p, k, v1, v2, Sign) VALUES ('2018-05-15', 5, 1000, 2000, -1), ('2018-05-17', 7, 5000, 6000, -1);
|
|
|
|
OPTIMIZE TABLE test.four_rows_per_granule FINAL;
|
|
|
|
SELECT COUNT(*) FROM test.four_rows_per_granule;
|
|
|
|
SELECT distinct(marks) from system.parts WHERE table = 'four_rows_per_granule' and database='test' and active=1;
|
|
|
|
DROP TABLE IF EXISTS test.four_rows_per_granule;
|