From 67db049297719ea829bbfc3a153282f87a3a3f31 Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Fri, 2 Feb 2018 16:20:28 +0300 Subject: [PATCH] moved tests for vertical merge into autotests [#CLICKHOUSE-3479] --- .../__init__.py | 0 .../configs/mergetree_settings.xml | 7 - .../test.py | 125 ------ ..._versioned_collapsing_merge_tree.reference | 396 +++++++++++++++--- .../00564_versioned_collapsing_merge_tree.sql | 107 ++++- 5 files changed, 440 insertions(+), 195 deletions(-) delete mode 100644 dbms/tests/integration/test_multiversion_merge_tree_vertical_merge/__init__.py delete mode 100644 dbms/tests/integration/test_multiversion_merge_tree_vertical_merge/configs/mergetree_settings.xml delete mode 100644 dbms/tests/integration/test_multiversion_merge_tree_vertical_merge/test.py diff --git a/dbms/tests/integration/test_multiversion_merge_tree_vertical_merge/__init__.py b/dbms/tests/integration/test_multiversion_merge_tree_vertical_merge/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/dbms/tests/integration/test_multiversion_merge_tree_vertical_merge/configs/mergetree_settings.xml b/dbms/tests/integration/test_multiversion_merge_tree_vertical_merge/configs/mergetree_settings.xml deleted file mode 100644 index 508b251c920..00000000000 --- a/dbms/tests/integration/test_multiversion_merge_tree_vertical_merge/configs/mergetree_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - 1 - 1 - 0 - - diff --git a/dbms/tests/integration/test_multiversion_merge_tree_vertical_merge/test.py b/dbms/tests/integration/test_multiversion_merge_tree_vertical_merge/test.py deleted file mode 100644 index 2f93036dce9..00000000000 --- a/dbms/tests/integration/test_multiversion_merge_tree_vertical_merge/test.py +++ /dev/null @@ -1,125 +0,0 @@ -import pytest - -from helpers.cluster import ClickHouseCluster - - -cluster = ClickHouseCluster(__file__) - -instance = cluster.add_instance('node', main_configs=['configs/mergetree_settings.xml']) - - - -@pytest.fixture(scope="module") -def started_cluster(): - try: - cluster.start() - - yield cluster - - finally: - cluster.shutdown() - - -def test(started_cluster): - - instance.query('create database if not exists test;') - - instance.query(''' - drop table if exists test.mult_tab; -create table test.mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(date, (date, version), 8192, sign, version); -insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10; -insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10; - ''') - - assert instance.query("select count() from test.mult_tab final;") == '0\n' - instance.query('optimize table test.mult_tab;') - assert instance.query("select count() from test.mult_tab;") == '2\n' - - - instance.query(''' -drop table if exists test.mult_tab; -create table test.mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(date, (date, value, version), 8192, sign, version); -insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10; -insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10; - ''') - - assert instance.query("select count() from test.mult_tab final;") == '20\n' - instance.query('optimize table test.mult_tab;') - assert instance.query("select count() from test.mult_tab;") == '20\n' - - - instance.query(''' -drop table if exists test.mult_tab; -create table test.mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(date, (date, value, version), 8192, sign, version); -insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10; -insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 10; - ''') - - assert instance.query("select count() from test.mult_tab final;") == '0\n' - instance.query('optimize table test.mult_tab;') - assert instance.query("select count() from test.mult_tab;") == '2\n' - - - instance.query(''' -drop table if exists test.mult_tab; -create table test.mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(date, (date, value, version), 8192, sign, version); -insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10; -insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 1, if(number % 2, -1, 1) from system.numbers limit 10; - ''') - - assert instance.query("select count() from test.mult_tab final;") == '20\n' - instance.query('optimize table test.mult_tab;') - assert instance.query("select count() from test.mult_tab;") == '20\n' - - - instance.query(''' -drop table if exists test.mult_tab; -create table test.mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(date, (date, value, version), 8192, sign, version); -insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10; -insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 10; -insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10; -insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 10; - ''') - - assert instance.query("select count() from test.mult_tab final;") == '0\n' - instance.query('optimize table test.mult_tab;') - assert instance.query("select count() from test.mult_tab;") == '2\n' - - - instance.query(''' -drop table if exists test.mult_tab; -create table test.mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(date, (date, value, version), 8192, sign, version); -insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10; -insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 10; -insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 1, if(number % 3 = 0, 1, -1) from system.numbers limit 10; -insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 1, if(number % 3 = 1, 1, -1) from system.numbers limit 10; -insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 1, if(number % 3 = 2, 1, -1) from system.numbers limit 10; - ''') - - assert instance.query("select count() from test.mult_tab final;") == '10\n' - instance.query('optimize table test.mult_tab;') - assert instance.query("select count() from test.mult_tab;") == '10\n' - - - instance.query(''' -drop table if exists test.mult_tab; -create table test.mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(date, (date, value, version), 8192, sign, version); -insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 1000000; -insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 1000000; - ''') - - assert instance.query("select count() from test.mult_tab final;") == '0\n' - instance.query('optimize table test.mult_tab;') - assert instance.query("select count() from test.mult_tab;") == '2\n' - - - instance.query(''' -drop table if exists test.mult_tab; -create table test.mult_tab (date Date, value UInt64, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(date, (date, version), 8192, sign, version); -insert into test.mult_tab select '2018-01-31', number, 0, if(number < 64, 1, -1) from system.numbers limit 128; -insert into test.mult_tab select '2018-01-31', number, 0, if(number < 64, -1, 1) from system.numbers limit 128; - ''') - - assert instance.query("select count() from test.mult_tab final settings max_block_size=32;") == '128\n' - instance.query('optimize table test.mult_tab;') - assert instance.query("select count() from test.mult_tab;") == '2\n' diff --git a/dbms/tests/queries/0_stateless/00564_versioned_collapsing_merge_tree.reference b/dbms/tests/queries/0_stateless/00564_versioned_collapsing_merge_tree.reference index a29af635f6c..edc91a8f558 100644 --- a/dbms/tests/queries/0_stateless/00564_versioned_collapsing_merge_tree.reference +++ b/dbms/tests/queries/0_stateless/00564_versioned_collapsing_merge_tree.reference @@ -160,38 +160,40 @@ table with 2 blocks final 2018-01-31 29 0 1 2018-01-31 30 0 1 2018-01-31 31 0 1 -2018-01-31 64 0 -1 -2018-01-31 65 0 -1 -2018-01-31 66 0 -1 -2018-01-31 67 0 -1 -2018-01-31 68 0 -1 -2018-01-31 69 0 -1 -2018-01-31 70 0 -1 -2018-01-31 71 0 -1 -2018-01-31 72 0 -1 -2018-01-31 73 0 -1 -2018-01-31 74 0 -1 -2018-01-31 75 0 -1 -2018-01-31 76 0 -1 -2018-01-31 77 0 -1 -2018-01-31 78 0 -1 -2018-01-31 79 0 -1 -2018-01-31 80 0 -1 -2018-01-31 81 0 -1 -2018-01-31 82 0 -1 -2018-01-31 83 0 -1 -2018-01-31 84 0 -1 -2018-01-31 85 0 -1 -2018-01-31 86 0 -1 -2018-01-31 87 0 -1 -2018-01-31 88 0 -1 -2018-01-31 89 0 -1 -2018-01-31 90 0 -1 -2018-01-31 91 0 -1 -2018-01-31 92 0 -1 -2018-01-31 93 0 -1 -2018-01-31 94 0 -1 +2018-01-31 32 0 1 2018-01-31 95 0 -1 +2018-01-31 96 0 -1 +2018-01-31 97 0 -1 +2018-01-31 98 0 -1 +2018-01-31 99 0 -1 +2018-01-31 100 0 -1 +2018-01-31 101 0 -1 +2018-01-31 102 0 -1 +2018-01-31 103 0 -1 +2018-01-31 104 0 -1 +2018-01-31 105 0 -1 +2018-01-31 106 0 -1 +2018-01-31 107 0 -1 +2018-01-31 108 0 -1 +2018-01-31 109 0 -1 +2018-01-31 110 0 -1 +2018-01-31 111 0 -1 +2018-01-31 112 0 -1 +2018-01-31 113 0 -1 +2018-01-31 114 0 -1 +2018-01-31 115 0 -1 +2018-01-31 116 0 -1 +2018-01-31 117 0 -1 +2018-01-31 118 0 -1 +2018-01-31 119 0 -1 +2018-01-31 120 0 -1 +2018-01-31 121 0 -1 +2018-01-31 122 0 -1 +2018-01-31 123 0 -1 +2018-01-31 124 0 -1 +2018-01-31 125 0 -1 +2018-01-31 126 0 -1 +2018-01-31 127 0 -1 2018-01-31 0 0 -1 2018-01-31 1 0 -1 2018-01-31 2 0 -1 @@ -224,38 +226,308 @@ table with 2 blocks final 2018-01-31 29 0 -1 2018-01-31 30 0 -1 2018-01-31 31 0 -1 -2018-01-31 64 0 1 -2018-01-31 65 0 1 -2018-01-31 66 0 1 -2018-01-31 67 0 1 -2018-01-31 68 0 1 -2018-01-31 69 0 1 -2018-01-31 70 0 1 -2018-01-31 71 0 1 -2018-01-31 72 0 1 -2018-01-31 73 0 1 -2018-01-31 74 0 1 -2018-01-31 75 0 1 -2018-01-31 76 0 1 -2018-01-31 77 0 1 -2018-01-31 78 0 1 -2018-01-31 79 0 1 -2018-01-31 80 0 1 -2018-01-31 81 0 1 -2018-01-31 82 0 1 -2018-01-31 83 0 1 -2018-01-31 84 0 1 -2018-01-31 85 0 1 -2018-01-31 86 0 1 -2018-01-31 87 0 1 -2018-01-31 88 0 1 -2018-01-31 89 0 1 -2018-01-31 90 0 1 -2018-01-31 91 0 1 -2018-01-31 92 0 1 -2018-01-31 93 0 1 -2018-01-31 94 0 1 +2018-01-31 32 0 -1 2018-01-31 95 0 1 +2018-01-31 96 0 1 +2018-01-31 97 0 1 +2018-01-31 98 0 1 +2018-01-31 99 0 1 +2018-01-31 100 0 1 +2018-01-31 101 0 1 +2018-01-31 102 0 1 +2018-01-31 103 0 1 +2018-01-31 104 0 1 +2018-01-31 105 0 1 +2018-01-31 106 0 1 +2018-01-31 107 0 1 +2018-01-31 108 0 1 +2018-01-31 109 0 1 +2018-01-31 110 0 1 +2018-01-31 111 0 1 +2018-01-31 112 0 1 +2018-01-31 113 0 1 +2018-01-31 114 0 1 +2018-01-31 115 0 1 +2018-01-31 116 0 1 +2018-01-31 117 0 1 +2018-01-31 118 0 1 +2018-01-31 119 0 1 +2018-01-31 120 0 1 +2018-01-31 121 0 1 +2018-01-31 122 0 1 +2018-01-31 123 0 1 +2018-01-31 124 0 1 +2018-01-31 125 0 1 +2018-01-31 126 0 1 +2018-01-31 127 0 1 +table with 2 blocks optimized +2018-01-31 0 0 -1 +2018-01-31 127 0 1 +######################### +Vertival merge +######################### +table with 2 blocks final +table with 2 blocks optimized +2018-01-31 str_8 0 -1 +2018-01-31 str_9 0 1 +######################### +table with 2 blocks final +2018-01-31 str_0 0 -1 +2018-01-31 str_0 0 -1 +2018-01-31 str_1 0 1 +2018-01-31 str_1 0 1 +2018-01-31 str_2 0 -1 +2018-01-31 str_2 0 -1 +2018-01-31 str_3 0 1 +2018-01-31 str_3 0 1 +2018-01-31 str_4 0 -1 +2018-01-31 str_4 0 -1 +2018-01-31 str_5 0 1 +2018-01-31 str_5 0 1 +2018-01-31 str_6 0 -1 +2018-01-31 str_6 0 -1 +2018-01-31 str_7 0 1 +2018-01-31 str_7 0 1 +2018-01-31 str_8 0 -1 +2018-01-31 str_8 0 -1 +2018-01-31 str_9 0 1 +2018-01-31 str_9 0 1 +table with 2 blocks optimized +2018-01-31 str_0 0 -1 +2018-01-31 str_0 0 -1 +2018-01-31 str_1 0 1 +2018-01-31 str_1 0 1 +2018-01-31 str_2 0 -1 +2018-01-31 str_2 0 -1 +2018-01-31 str_3 0 1 +2018-01-31 str_3 0 1 +2018-01-31 str_4 0 -1 +2018-01-31 str_4 0 -1 +2018-01-31 str_5 0 1 +2018-01-31 str_5 0 1 +2018-01-31 str_6 0 -1 +2018-01-31 str_6 0 -1 +2018-01-31 str_7 0 1 +2018-01-31 str_7 0 1 +2018-01-31 str_8 0 -1 +2018-01-31 str_8 0 -1 +2018-01-31 str_9 0 1 +2018-01-31 str_9 0 1 +######################### +table with 2 blocks final +table with 2 blocks optimized +2018-01-31 str_9 0 1 +2018-01-31 str_9 0 -1 +######################### +table with 2 blocks final +2018-01-31 str_0 0 -1 +2018-01-31 str_0 1 1 +2018-01-31 str_1 0 1 +2018-01-31 str_1 1 -1 +2018-01-31 str_2 0 -1 +2018-01-31 str_2 1 1 +2018-01-31 str_3 0 1 +2018-01-31 str_3 1 -1 +2018-01-31 str_4 0 -1 +2018-01-31 str_4 1 1 +2018-01-31 str_5 0 1 +2018-01-31 str_5 1 -1 +2018-01-31 str_6 0 -1 +2018-01-31 str_6 1 1 +2018-01-31 str_7 0 1 +2018-01-31 str_7 1 -1 +2018-01-31 str_8 0 -1 +2018-01-31 str_8 1 1 +2018-01-31 str_9 0 1 +2018-01-31 str_9 1 -1 +table with 2 blocks optimized +2018-01-31 str_0 0 -1 +2018-01-31 str_0 1 1 +2018-01-31 str_1 0 1 +2018-01-31 str_1 1 -1 +2018-01-31 str_2 0 -1 +2018-01-31 str_2 1 1 +2018-01-31 str_3 0 1 +2018-01-31 str_3 1 -1 +2018-01-31 str_4 0 -1 +2018-01-31 str_4 1 1 +2018-01-31 str_5 0 1 +2018-01-31 str_5 1 -1 +2018-01-31 str_6 0 -1 +2018-01-31 str_6 1 1 +2018-01-31 str_7 0 1 +2018-01-31 str_7 1 -1 +2018-01-31 str_8 0 -1 +2018-01-31 str_8 1 1 +2018-01-31 str_9 0 1 +2018-01-31 str_9 1 -1 +######################### +table with 4 blocks final +table with 4 blocks optimized +2018-01-31 str_9 0 1 +2018-01-31 str_9 0 -1 +######################### +table with 5 blocks final +2018-01-31 str_0 1 -1 +2018-01-31 str_1 1 -1 +2018-01-31 str_2 1 -1 +2018-01-31 str_3 1 -1 +2018-01-31 str_4 1 -1 +2018-01-31 str_5 1 -1 +2018-01-31 str_6 1 -1 +2018-01-31 str_7 1 -1 +2018-01-31 str_8 1 -1 +2018-01-31 str_9 1 -1 +table with 5 blocks optimized +2018-01-31 str_0 1 -1 +2018-01-31 str_1 1 -1 +2018-01-31 str_2 1 -1 +2018-01-31 str_3 1 -1 +2018-01-31 str_4 1 -1 +2018-01-31 str_5 1 -1 +2018-01-31 str_6 1 -1 +2018-01-31 str_7 1 -1 +2018-01-31 str_8 1 -1 +2018-01-31 str_9 1 -1 +######################### +table with 2 blocks final +table with 2 blocks optimized +2018-01-31 str_999999 0 1 +2018-01-31 str_999999 0 -1 +######################### +table with 2 blocks final +2018-01-31 0 0 1 +2018-01-31 1 0 1 +2018-01-31 2 0 1 +2018-01-31 3 0 1 +2018-01-31 4 0 1 +2018-01-31 5 0 1 +2018-01-31 6 0 1 +2018-01-31 7 0 1 +2018-01-31 8 0 1 +2018-01-31 9 0 1 +2018-01-31 10 0 1 +2018-01-31 11 0 1 +2018-01-31 12 0 1 +2018-01-31 13 0 1 +2018-01-31 14 0 1 +2018-01-31 15 0 1 +2018-01-31 16 0 1 +2018-01-31 17 0 1 +2018-01-31 18 0 1 +2018-01-31 19 0 1 +2018-01-31 20 0 1 +2018-01-31 21 0 1 +2018-01-31 22 0 1 +2018-01-31 23 0 1 +2018-01-31 24 0 1 +2018-01-31 25 0 1 +2018-01-31 26 0 1 +2018-01-31 27 0 1 +2018-01-31 28 0 1 +2018-01-31 29 0 1 +2018-01-31 30 0 1 +2018-01-31 31 0 1 +2018-01-31 32 0 1 +2018-01-31 95 0 -1 +2018-01-31 96 0 -1 +2018-01-31 97 0 -1 +2018-01-31 98 0 -1 +2018-01-31 99 0 -1 +2018-01-31 100 0 -1 +2018-01-31 101 0 -1 +2018-01-31 102 0 -1 +2018-01-31 103 0 -1 +2018-01-31 104 0 -1 +2018-01-31 105 0 -1 +2018-01-31 106 0 -1 +2018-01-31 107 0 -1 +2018-01-31 108 0 -1 +2018-01-31 109 0 -1 +2018-01-31 110 0 -1 +2018-01-31 111 0 -1 +2018-01-31 112 0 -1 +2018-01-31 113 0 -1 +2018-01-31 114 0 -1 +2018-01-31 115 0 -1 +2018-01-31 116 0 -1 +2018-01-31 117 0 -1 +2018-01-31 118 0 -1 +2018-01-31 119 0 -1 +2018-01-31 120 0 -1 +2018-01-31 121 0 -1 +2018-01-31 122 0 -1 +2018-01-31 123 0 -1 +2018-01-31 124 0 -1 +2018-01-31 125 0 -1 +2018-01-31 126 0 -1 +2018-01-31 127 0 -1 +2018-01-31 0 0 -1 +2018-01-31 1 0 -1 +2018-01-31 2 0 -1 +2018-01-31 3 0 -1 +2018-01-31 4 0 -1 +2018-01-31 5 0 -1 +2018-01-31 6 0 -1 +2018-01-31 7 0 -1 +2018-01-31 8 0 -1 +2018-01-31 9 0 -1 +2018-01-31 10 0 -1 +2018-01-31 11 0 -1 +2018-01-31 12 0 -1 +2018-01-31 13 0 -1 +2018-01-31 14 0 -1 +2018-01-31 15 0 -1 +2018-01-31 16 0 -1 +2018-01-31 17 0 -1 +2018-01-31 18 0 -1 +2018-01-31 19 0 -1 +2018-01-31 20 0 -1 +2018-01-31 21 0 -1 +2018-01-31 22 0 -1 +2018-01-31 23 0 -1 +2018-01-31 24 0 -1 +2018-01-31 25 0 -1 +2018-01-31 26 0 -1 +2018-01-31 27 0 -1 +2018-01-31 28 0 -1 +2018-01-31 29 0 -1 +2018-01-31 30 0 -1 +2018-01-31 31 0 -1 +2018-01-31 32 0 -1 +2018-01-31 95 0 1 +2018-01-31 96 0 1 +2018-01-31 97 0 1 +2018-01-31 98 0 1 +2018-01-31 99 0 1 +2018-01-31 100 0 1 +2018-01-31 101 0 1 +2018-01-31 102 0 1 +2018-01-31 103 0 1 +2018-01-31 104 0 1 +2018-01-31 105 0 1 +2018-01-31 106 0 1 +2018-01-31 107 0 1 +2018-01-31 108 0 1 +2018-01-31 109 0 1 +2018-01-31 110 0 1 +2018-01-31 111 0 1 +2018-01-31 112 0 1 +2018-01-31 113 0 1 +2018-01-31 114 0 1 +2018-01-31 115 0 1 +2018-01-31 116 0 1 +2018-01-31 117 0 1 +2018-01-31 118 0 1 +2018-01-31 119 0 1 +2018-01-31 120 0 1 +2018-01-31 121 0 1 +2018-01-31 122 0 1 +2018-01-31 123 0 1 +2018-01-31 124 0 1 +2018-01-31 125 0 1 +2018-01-31 126 0 1 +2018-01-31 127 0 1 table with 2 blocks optimized 2018-01-31 0 0 -1 2018-01-31 127 0 1 diff --git a/dbms/tests/queries/0_stateless/00564_versioned_collapsing_merge_tree.sql b/dbms/tests/queries/0_stateless/00564_versioned_collapsing_merge_tree.sql index 541de5bac19..3b5d7adb4ea 100644 --- a/dbms/tests/queries/0_stateless/00564_versioned_collapsing_merge_tree.sql +++ b/dbms/tests/queries/0_stateless/00564_versioned_collapsing_merge_tree.sql @@ -92,7 +92,112 @@ create table test.mult_tab (date Date, value UInt64, version UInt64, sign Int8) insert into test.mult_tab select '2018-01-31', number, 0, if(number < 64, 1, -1) from system.numbers limit 128; insert into test.mult_tab select '2018-01-31', number, 0, if(number < 64, -1, 1) from system.numbers limit 128; select 'table with 2 blocks final'; -select * from test.mult_tab final settings max_block_size=32; +select * from test.mult_tab final settings max_block_size=33; optimize table test.mult_tab; select 'table with 2 blocks optimized'; select * from test.mult_tab; + +select '#########################'; +select 'Vertival merge'; +select '#########################'; + +drop table if exists test.mult_tab; +create table test.mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(sign, version) order by (date, version) settings enable_vertical_merge_algorithm = 1, vertical_merge_algorithm_min_rows_to_activate = 1, vertical_merge_algorithm_min_columns_to_activate = 0; +insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10; +insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10; +select 'table with 2 blocks final'; +select * from test.mult_tab final; +optimize table test.mult_tab; +select 'table with 2 blocks optimized'; +select * from test.mult_tab; + +select '#########################'; + +drop table if exists test.mult_tab; +create table test.mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(sign, version) order by (date, value, version) settings enable_vertical_merge_algorithm = 1, vertical_merge_algorithm_min_rows_to_activate = 1, vertical_merge_algorithm_min_columns_to_activate = 0; +insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10; +insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10; +select 'table with 2 blocks final'; +select * from test.mult_tab final; +optimize table test.mult_tab; +select 'table with 2 blocks optimized'; +select * from test.mult_tab; + +select '#########################'; + +drop table if exists test.mult_tab; +create table test.mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(sign, version) order by (date, value, version) settings enable_vertical_merge_algorithm = 1, vertical_merge_algorithm_min_rows_to_activate = 1, vertical_merge_algorithm_min_columns_to_activate = 0; +insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10; +insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 10; +select 'table with 2 blocks final'; +select * from test.mult_tab final; +optimize table test.mult_tab; +select 'table with 2 blocks optimized'; +select * from test.mult_tab; + +select '#########################'; + +drop table if exists test.mult_tab; +create table test.mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(sign, version) order by (date, value, version) settings enable_vertical_merge_algorithm = 1, vertical_merge_algorithm_min_rows_to_activate = 1, vertical_merge_algorithm_min_columns_to_activate = 0; +insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10; +insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 1, if(number % 2, -1, 1) from system.numbers limit 10; +select 'table with 2 blocks final'; +select * from test.mult_tab final; +optimize table test.mult_tab; +select 'table with 2 blocks optimized'; +select * from test.mult_tab; + +select '#########################'; + +drop table if exists test.mult_tab; +create table test.mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(sign, version) order by (date, value, version) settings enable_vertical_merge_algorithm = 1, vertical_merge_algorithm_min_rows_to_activate = 1, vertical_merge_algorithm_min_columns_to_activate = 0; +insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10; +insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 10; +insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10; +insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 10; +select 'table with 4 blocks final'; +select * from test.mult_tab final; +optimize table test.mult_tab; +select 'table with 4 blocks optimized'; +select * from test.mult_tab; + +select '#########################'; + +drop table if exists test.mult_tab; +create table test.mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(sign, version) order by (date, value, version) settings enable_vertical_merge_algorithm = 1, vertical_merge_algorithm_min_rows_to_activate = 1, vertical_merge_algorithm_min_columns_to_activate = 0; +insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 10; +insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 10; +insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 1, if(number % 3 = 0, 1, -1) from system.numbers limit 10; +insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 1, if(number % 3 = 1, 1, -1) from system.numbers limit 10; +insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 1, if(number % 3 = 2, 1, -1) from system.numbers limit 10; +select 'table with 5 blocks final'; +select * from test.mult_tab final; +optimize table test.mult_tab; +select 'table with 5 blocks optimized'; +select * from test.mult_tab; + +select '#########################'; + +drop table if exists test.mult_tab; +create table test.mult_tab (date Date, value String, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(sign, version) order by (date, value, version) settings enable_vertical_merge_algorithm = 1, vertical_merge_algorithm_min_rows_to_activate = 1, vertical_merge_algorithm_min_columns_to_activate = 0; +insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, 1, -1) from system.numbers limit 1000000; +insert into test.mult_tab select '2018-01-31', 'str_' || toString(number), 0, if(number % 2, -1, 1) from system.numbers limit 1000000; +select 'table with 2 blocks final'; +select * from test.mult_tab final; +optimize table test.mult_tab; +select 'table with 2 blocks optimized'; +select * from test.mult_tab; + +select '#########################'; + +drop table if exists test.mult_tab; +create table test.mult_tab (date Date, value UInt64, version UInt64, sign Int8) engine = VersionedCollapsingMergeTree(sign, version) order by (date, version) settings enable_vertical_merge_algorithm = 1, vertical_merge_algorithm_min_rows_to_activate = 1, vertical_merge_algorithm_min_columns_to_activate = 0; +insert into test.mult_tab select '2018-01-31', number, 0, if(number < 64, 1, -1) from system.numbers limit 128; +insert into test.mult_tab select '2018-01-31', number, 0, if(number < 64, -1, 1) from system.numbers limit 128; +select 'table with 2 blocks final'; +select * from test.mult_tab final settings max_block_size=33; +optimize table test.mult_tab; +select 'table with 2 blocks optimized'; +select * from test.mult_tab; + +