From cd7a5290b24fb1d3b560c6b990f29298ac4e9c4b Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Fri, 2 Feb 2018 17:07:40 +0300 Subject: [PATCH] added tests for ReplicatedVersionedCollapsingMergeTree creation [#CLICKHOUSE-3479] --- .../00083_create_merge_tree_zookeeper.sql | 20 +++++++++++++++++++ ...rage_definition_syntax_zookeeper.reference | 4 ++++ ...ed_storage_definition_syntax_zookeeper.sql | 18 +++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/dbms/tests/queries/0_stateless/00083_create_merge_tree_zookeeper.sql b/dbms/tests/queries/0_stateless/00083_create_merge_tree_zookeeper.sql index ed9dc50fbbc..4e47f0f7fdf 100644 --- a/dbms/tests/queries/0_stateless/00083_create_merge_tree_zookeeper.sql +++ b/dbms/tests/queries/0_stateless/00083_create_merge_tree_zookeeper.sql @@ -1,23 +1,27 @@ DROP TABLE IF EXISTS test.merge_tree; DROP TABLE IF EXISTS test.collapsing_merge_tree; +DROP TABLE IF EXISTS test.versioned_collapsing_merge_tree; DROP TABLE IF EXISTS test.summing_merge_tree; DROP TABLE IF EXISTS test.summing_merge_tree_with_list_of_columns_to_sum; DROP TABLE IF EXISTS test.aggregating_merge_tree; DROP TABLE IF EXISTS test.merge_tree_with_sampling; DROP TABLE IF EXISTS test.collapsing_merge_tree_with_sampling; +DROP TABLE IF EXISTS test.versioned_collapsing_merge_tree_with_sampling; DROP TABLE IF EXISTS test.summing_merge_tree_with_sampling; DROP TABLE IF EXISTS test.summing_merge_tree_with_sampling_with_list_of_columns_to_sum; DROP TABLE IF EXISTS test.aggregating_merge_tree_with_sampling; DROP TABLE IF EXISTS test.replicated_merge_tree; DROP TABLE IF EXISTS test.replicated_collapsing_merge_tree; +DROP TABLE IF EXISTS test.replicated_versioned_collapsing_merge_tree; DROP TABLE IF EXISTS test.replicated_summing_merge_tree; DROP TABLE IF EXISTS test.replicated_summing_merge_tree_with_list_of_columns_to_sum; DROP TABLE IF EXISTS test.replicated_aggregating_merge_tree; DROP TABLE IF EXISTS test.replicated_merge_tree_with_sampling; DROP TABLE IF EXISTS test.replicated_collapsing_merge_tree_with_sampling; +DROP TABLE IF EXISTS test.replicated_versioned_collapsing_merge_tree_with_sampling; DROP TABLE IF EXISTS test.replicated_summing_merge_tree_with_sampling; DROP TABLE IF EXISTS test.replicated_summing_merge_tree_with_sampling_with_list_of_columns_to_sum; DROP TABLE IF EXISTS test.replicated_aggregating_merge_tree_with_sampling; @@ -27,6 +31,8 @@ CREATE TABLE test.merge_tree (d Date, a String, b UInt8, x String, y Int8, z UInt32) ENGINE = MergeTree(d, (a, b), 111); CREATE TABLE test.collapsing_merge_tree (d Date, a String, b UInt8, x String, y Int8, z UInt32) ENGINE = CollapsingMergeTree(d, (a, b), 111, y); +CREATE TABLE test.versioned_collapsing_merge_tree + (d Date, a String, b UInt8, x String, y Int8, z UInt32) ENGINE = VersionedCollapsingMergeTree(d, (a, b), 111, y, b); CREATE TABLE test.summing_merge_tree (d Date, a String, b UInt8, x String, y Int8, z UInt32) ENGINE = SummingMergeTree(d, (a, b), 111); CREATE TABLE test.summing_merge_tree_with_list_of_columns_to_sum @@ -38,6 +44,8 @@ CREATE TABLE test.merge_tree_with_sampling (d Date, a String, b UInt8, x String, y Int8, z UInt32) ENGINE = MergeTree(d, sipHash64(a) + b, (a, sipHash64(a) + b), 111); CREATE TABLE test.collapsing_merge_tree_with_sampling (d Date, a String, b UInt8, x String, y Int8, z UInt32) ENGINE = CollapsingMergeTree(d, sipHash64(a) + b, (a, sipHash64(a) + b), 111, y); +CREATE TABLE test.versioned_collapsing_merge_tree_with_sampling + (d Date, a String, b UInt8, x String, y Int8, z UInt32) ENGINE = VersionedCollapsingMergeTree(d, sipHash64(a) + b, (a, sipHash64(a) + b, b), 111, y, b); CREATE TABLE test.summing_merge_tree_with_sampling (d Date, a String, b UInt8, x String, y Int8, z UInt32) ENGINE = SummingMergeTree(d, sipHash64(a) + b, (a, sipHash64(a) + b), 111); CREATE TABLE test.summing_merge_tree_with_sampling_with_list_of_columns_to_sum @@ -49,6 +57,8 @@ CREATE TABLE test.replicated_merge_tree (d Date, a String, b UInt8, x String, y Int8, z UInt32) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test/01/replicated_merge_tree/', 'r1', d, (a, b), 111); CREATE TABLE test.replicated_collapsing_merge_tree (d Date, a String, b UInt8, x String, y Int8, z UInt32) ENGINE = ReplicatedCollapsingMergeTree('/clickhouse/tables/test/01/replicated_collapsing_merge_tree/', 'r1', d, (a, b), 111, y); +CREATE TABLE test.replicated_versioned_collapsing_merge_tree + (d Date, a String, b UInt8, x String, y Int8, z UInt32) ENGINE = ReplicatedVersionedCollapsingMergeTree('/clickhouse/tables/test/01/replicated_versioned_collapsing_merge_tree/', 'r1', d, (a, b), 111, y, b); CREATE TABLE test.replicated_summing_merge_tree (d Date, a String, b UInt8, x String, y Int8, z UInt32) ENGINE = ReplicatedSummingMergeTree('/clickhouse/tables/test/01/replicated_summing_merge_tree/', 'r1', d, (a, b), 111); CREATE TABLE test.replicated_summing_merge_tree_with_list_of_columns_to_sum @@ -60,6 +70,8 @@ CREATE TABLE test.replicated_merge_tree_with_sampling (d Date, a String, b UInt8, x String, y Int8, z UInt32) ENGINE = ReplicatedMergeTree('/clickhouse/tables/test/01/replicated_merge_tree_with_sampling/', 'r1', d, sipHash64(a) + b, (a, sipHash64(a) + b), 111); CREATE TABLE test.replicated_collapsing_merge_tree_with_sampling (d Date, a String, b UInt8, x String, y Int8, z UInt32) ENGINE = ReplicatedCollapsingMergeTree('/clickhouse/tables/test/01/replicated_collapsing_merge_tree_with_sampling/', 'r1', d, sipHash64(a) + b, (a, sipHash64(a) + b), 111, y); +CREATE TABLE test.replicated_versioned_collapsing_merge_tree_with_sampling + (d Date, a String, b UInt8, x String, y Int8, z UInt32) ENGINE = ReplicatedVersionedCollapsingMergeTree('/clickhouse/tables/test/01/replicated_versioned_collapsing_merge_tree_with_sampling/', 'r1', d, sipHash64(a) + b, (a, sipHash64(a) + b, b), 111, y, b); CREATE TABLE test.replicated_summing_merge_tree_with_sampling (d Date, a String, b UInt8, x String, y Int8, z UInt32) ENGINE = ReplicatedSummingMergeTree('/clickhouse/tables/test/01/replicated_summing_merge_tree_with_sampling/', 'r1', d, sipHash64(a) + b, (a, sipHash64(a) + b), 111); CREATE TABLE test.replicated_summing_merge_tree_with_sampling_with_list_of_columns_to_sum @@ -70,24 +82,28 @@ CREATE TABLE test.replicated_aggregating_merge_tree_with_sampling INSERT INTO test.merge_tree VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); INSERT INTO test.collapsing_merge_tree VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); +INSERT INTO test.versioned_collapsing_merge_tree VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); INSERT INTO test.summing_merge_tree VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); INSERT INTO test.summing_merge_tree_with_list_of_columns_to_sum VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); INSERT INTO test.aggregating_merge_tree VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); INSERT INTO test.merge_tree_with_sampling VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); INSERT INTO test.collapsing_merge_tree_with_sampling VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); +INSERT INTO test.versioned_collapsing_merge_tree_with_sampling VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); INSERT INTO test.summing_merge_tree_with_sampling VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); INSERT INTO test.summing_merge_tree_with_sampling_with_list_of_columns_to_sum VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); INSERT INTO test.aggregating_merge_tree_with_sampling VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); INSERT INTO test.replicated_merge_tree VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); INSERT INTO test.replicated_collapsing_merge_tree VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); +INSERT INTO test.replicated_versioned_collapsing_merge_tree VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); INSERT INTO test.replicated_summing_merge_tree VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); INSERT INTO test.replicated_summing_merge_tree_with_list_of_columns_to_sum VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); INSERT INTO test.replicated_aggregating_merge_tree VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); INSERT INTO test.replicated_merge_tree_with_sampling VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); INSERT INTO test.replicated_collapsing_merge_tree_with_sampling VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); +INSERT INTO test.replicated_versioned_collapsing_merge_tree_with_sampling VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); INSERT INTO test.replicated_summing_merge_tree_with_sampling VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); INSERT INTO test.replicated_summing_merge_tree_with_sampling_with_list_of_columns_to_sum VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); INSERT INTO test.replicated_aggregating_merge_tree_with_sampling VALUES ('2000-01-01', 'Hello, world!', 123, 'xxx yyy', -123, 123456789); @@ -95,24 +111,28 @@ INSERT INTO test.replicated_aggregating_merge_tree_with_sampling VALUES ('2000-0 DROP TABLE test.merge_tree; DROP TABLE test.collapsing_merge_tree; +DROP TABLE test.versioned_collapsing_merge_tree; DROP TABLE test.summing_merge_tree; DROP TABLE test.summing_merge_tree_with_list_of_columns_to_sum; DROP TABLE test.aggregating_merge_tree; DROP TABLE test.merge_tree_with_sampling; DROP TABLE test.collapsing_merge_tree_with_sampling; +DROP TABLE test.versioned_collapsing_merge_tree_with_sampling; DROP TABLE test.summing_merge_tree_with_sampling; DROP TABLE test.summing_merge_tree_with_sampling_with_list_of_columns_to_sum; DROP TABLE test.aggregating_merge_tree_with_sampling; DROP TABLE test.replicated_merge_tree; DROP TABLE test.replicated_collapsing_merge_tree; +DROP TABLE test.replicated_versioned_collapsing_merge_tree; DROP TABLE test.replicated_summing_merge_tree; DROP TABLE test.replicated_summing_merge_tree_with_list_of_columns_to_sum; DROP TABLE test.replicated_aggregating_merge_tree; DROP TABLE test.replicated_merge_tree_with_sampling; DROP TABLE test.replicated_collapsing_merge_tree_with_sampling; +DROP TABLE test.replicated_versioned_collapsing_merge_tree_with_sampling; DROP TABLE test.replicated_summing_merge_tree_with_sampling; DROP TABLE test.replicated_summing_merge_tree_with_sampling_with_list_of_columns_to_sum; DROP TABLE test.replicated_aggregating_merge_tree_with_sampling; diff --git a/dbms/tests/queries/0_stateless/00509_extended_storage_definition_syntax_zookeeper.reference b/dbms/tests/queries/0_stateless/00509_extended_storage_definition_syntax_zookeeper.reference index 28e6a775e09..e594d55eb4b 100644 --- a/dbms/tests/queries/0_stateless/00509_extended_storage_definition_syntax_zookeeper.reference +++ b/dbms/tests/queries/0_stateless/00509_extended_storage_definition_syntax_zookeeper.reference @@ -4,6 +4,10 @@ 2017-10-23 1 c *** Replicated Collapsing *** 2017-10-23 2 1 +*** Replicated VersionedCollapsing *** +2017-10-23 2 1 0 +2017-10-23 1 -1 1 +2017-10-23 2 1 2 *** Table definition with SETTINGS *** 0 0 diff --git a/dbms/tests/queries/0_stateless/00509_extended_storage_definition_syntax_zookeeper.sql b/dbms/tests/queries/0_stateless/00509_extended_storage_definition_syntax_zookeeper.sql index d5bfc3996ed..d71baeec005 100644 --- a/dbms/tests/queries/0_stateless/00509_extended_storage_definition_syntax_zookeeper.sql +++ b/dbms/tests/queries/0_stateless/00509_extended_storage_definition_syntax_zookeeper.sql @@ -45,6 +45,24 @@ SELECT * FROM test.replicated_collapsing; DROP TABLE test.replicated_collapsing; +SELECT '*** Replicated VersionedCollapsing ***'; + +DROP TABLE IF EXISTS test.replicated_versioned_collapsing; + +CREATE TABLE test.replicated_versioned_collapsing(d Date, x UInt32, sign Int8, version UInt8) + ENGINE = ReplicatedVersionedCollapsingMergeTree('/clickhouse/tables/test/replicated_versioned_collapsing', 'r1', sign, version) + PARTITION BY toYYYYMM(d) ORDER BY (d, version); + +INSERT INTO test.replicated_versioned_collapsing VALUES ('2017-10-23', 1, 1, 0); +INSERT INTO test.replicated_versioned_collapsing VALUES ('2017-10-23', 1, -1, 0), ('2017-10-23', 2, 1, 0); +INSERT INTO test.replicated_versioned_collapsing VALUES ('2017-10-23', 1, -1, 1), ('2017-10-23', 2, 1, 2); + +OPTIMIZE TABLE test.replicated_versioned_collapsing PARTITION 201710 FINAL; + +SELECT * FROM test.replicated_versioned_collapsing; + +DROP TABLE test.replicated_versioned_collapsing; + SELECT '*** Table definition with SETTINGS ***'; DROP TABLE IF EXISTS test.with_settings;