modify test cases

This commit is contained in:
terrylin 2021-07-31 22:34:51 +08:00
parent 79c55866b5
commit d0b44a3d5d
4 changed files with 92 additions and 43 deletions

View File

@ -1,9 +1,11 @@
drop table if exists ttl;
set mutations_sync = 2;
set materialize_ttl_after_modify = 0;
drop table if exists ttl;
create table ttl (d Date, a Int) engine = MergeTree order by a partition by toDayOfMonth(d)
SETTINGS merge_with_ttl_timeout=0,max_number_of_merges_with_ttl_in_pool=0;
SETTINGS merge_with_ttl_timeout=0;
SYSTEM STOP TTL MERGES;
insert into ttl values (toDateTime('2000-10-10 00:00:00'), 1);
insert into ttl values (toDateTime('2000-10-10 00:00:00'), 2);
@ -18,35 +20,43 @@ select * from ttl order by a;
alter table ttl materialize ttl;
select * from ttl order by a;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 1;
SYSTEM START TTL MERGES;
optimize table ttl;
select * from ttl order by a;
drop table if exists ttl;
create table ttl (i Int, s String) engine = MergeTree order by i
SETTINGS merge_with_ttl_timeout=0,max_number_of_merges_with_ttl_in_pool=0;
SETTINGS merge_with_ttl_timeout=0;
SYSTEM STOP TTL MERGES;
insert into ttl values (1, 'a') (2, 'b') (3, 'c') (4, 'd');
alter table ttl modify ttl i % 2 = 0 ? today() - 10 : toDate('2100-01-01');
alter table ttl materialize ttl;
select * from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 1;
SYSTEM START TTL MERGES;
optimize table ttl;
SYSTEM STOP TTL MERGES;
select * from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 0;
alter table ttl modify ttl toDate('2000-01-01');
alter table ttl materialize ttl;
select * from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 1;
SYSTEM START TTL MERGES;
optimize table ttl;
SYSTEM STOP TTL MERGES;
select * from ttl order by i;
drop table if exists ttl;
create table ttl (i Int, s String) engine = MergeTree order by i
SETTINGS merge_with_ttl_timeout=0,max_number_of_merges_with_ttl_in_pool=0;
SETTINGS merge_with_ttl_timeout=0;
SYSTEM STOP TTL MERGES;
insert into ttl values (1, 'a') (2, 'b') (3, 'c') (4, 'd');
alter table ttl modify column s String ttl i % 2 = 0 ? today() - 10 : toDate('2100-01-01');
@ -55,38 +65,45 @@ select * from ttl order by i;
alter table ttl materialize ttl;
select * from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 1;
SYSTEM START TTL MERGES;
optimize table ttl;
SYSTEM STOP TTL MERGES;
select * from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 0;
alter table ttl modify column s String ttl toDate('2000-01-01');
alter table ttl materialize ttl;
select * from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 1;
SYSTEM START TTL MERGES;
optimize table ttl;
SYSTEM STOP TTL MERGES;
select * from ttl order by i;
drop table if exists ttl;
create table ttl (d Date, i Int, s String) engine = MergeTree order by i
SETTINGS merge_with_ttl_timeout=0,max_number_of_merges_with_ttl_in_pool=0;
SETTINGS merge_with_ttl_timeout=0;
SYSTEM STOP TTL MERGES;
insert into ttl values (toDate('2000-01-02'), 1, 'a') (toDate('2000-01-03'), 2, 'b') (toDate('2080-01-01'), 3, 'c') (toDate('2080-01-03'), 4, 'd');
alter table ttl modify ttl i % 3 = 0 ? today() - 10 : toDate('2100-01-01');
alter table ttl materialize ttl;
select i, s from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 1;
SYSTEM START TTL MERGES;
optimize table ttl;
SYSTEM STOP TTL MERGES;
select i, s from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 0;
alter table ttl modify column s String ttl d + interval 1 month;
alter table ttl materialize ttl;
select i, s from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 1;
SYSTEM START TTL MERGES;
optimize table ttl;
SYSTEM STOP TTL MERGES;
select i, s from ttl order by i;
drop table if exists ttl;

View File

@ -2,7 +2,8 @@ drop table if exists ttl;
set mutations_sync = 2;
create table ttl (d Date, a Int) engine = MergeTree order by a partition by toDayOfMonth(d)
SETTINGS merge_with_ttl_timeout=0,max_number_of_merges_with_ttl_in_pool=0;
SETTINGS merge_with_ttl_timeout=0;
SYSTEM STOP TTL MERGES;
insert into ttl values (toDateTime('2000-10-10 00:00:00'), 1);
insert into ttl values (toDateTime('2000-10-10 00:00:00'), 2);
@ -11,90 +12,108 @@ insert into ttl values (toDateTime('2100-10-10 00:00:00'), 4);
alter table ttl modify ttl d + interval 1 day;
select * from ttl order by a;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 1;
SYSTEM START TTL MERGES;
optimize table ttl;
SYSTEM STOP TTL MERGES;
select * from ttl order by a;
select '=============';
drop table if exists ttl;
create table ttl (i Int, s String) engine = MergeTree order by i
SETTINGS merge_with_ttl_timeout=0,max_number_of_merges_with_ttl_in_pool=0;
SETTINGS merge_with_ttl_timeout=0;
SYSTEM STOP TTL MERGES;
insert into ttl values (1, 'a') (2, 'b') (3, 'c') (4, 'd');
alter table ttl modify ttl i % 2 = 0 ? today() - 10 : toDate('2100-01-01');
select * from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 1;
SYSTEM START TTL MERGES;
optimize table ttl;
SYSTEM STOP TTL MERGES;
select * from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 0;
select '=============';
alter table ttl modify ttl toDate('2000-01-01');
select * from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 1;
SYSTEM START TTL MERGES;
optimize table ttl;
SYSTEM STOP TTL MERGES;
select * from ttl order by i;
select '=============';
drop table if exists ttl;
create table ttl (i Int, s String) engine = MergeTree order by i
SETTINGS merge_with_ttl_timeout=0,max_number_of_merges_with_ttl_in_pool=0;
SETTINGS merge_with_ttl_timeout=0;
SYSTEM STOP TTL MERGES;
insert into ttl values (1, 'a') (2, 'b') (3, 'c') (4, 'd');
alter table ttl modify column s String ttl i % 2 = 0 ? today() - 10 : toDate('2100-01-01');
select * from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 1;
SYSTEM START TTL MERGES;
optimize table ttl;
SYSTEM STOP TTL MERGES;
select * from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 0;
select '=============';
alter table ttl modify column s String ttl toDate('2000-01-01');
select * from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 1;
SYSTEM START TTL MERGES;
optimize table ttl;
SYSTEM STOP TTL MERGES;
select * from ttl order by i;
select '=============';
drop table if exists ttl;
create table ttl (d Date, i Int, s String) engine = MergeTree order by i
SETTINGS merge_with_ttl_timeout=0,max_number_of_merges_with_ttl_in_pool=0;
SETTINGS merge_with_ttl_timeout=0;
SYSTEM STOP TTL MERGES;
insert into ttl values (toDate('2000-01-02'), 1, 'a') (toDate('2000-01-03'), 2, 'b') (toDate('2080-01-01'), 3, 'c') (toDate('2080-01-03'), 4, 'd');
alter table ttl modify ttl i % 3 = 0 ? today() - 10 : toDate('2100-01-01');
select i, s from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 1;
SYSTEM START TTL MERGES;
optimize table ttl;
SYSTEM STOP TTL MERGES;
select i, s from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 0;
select '=============';
alter table ttl modify column s String ttl d + interval 1 month;
select i, s from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 1;
SYSTEM START TTL MERGES;
optimize table ttl;
SYSTEM STOP TTL MERGES;
select i, s from ttl order by i;
select '=============';
drop table if exists ttl;
create table ttl (i Int, s String, t String) engine = MergeTree order by i
SETTINGS merge_with_ttl_timeout=0,max_number_of_merges_with_ttl_in_pool=0;
SETTINGS merge_with_ttl_timeout=0;
SYSTEM STOP TTL MERGES;
insert into ttl values (1, 'a', 'aa') (2, 'b', 'bb') (3, 'c', 'cc') (4, 'd', 'dd');
alter table ttl modify column s String ttl i % 3 = 0 ? today() - 10 : toDate('2100-01-01'),
modify column t String ttl i % 3 = 1 ? today() - 10 : toDate('2100-01-01');
select i, s, t from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 1;
SYSTEM START TTL MERGES;
optimize table ttl;
SYSTEM STOP TTL MERGES;
select i, s, t from ttl order by i;
-- MATERIALIZE TTL ran only once
select count() from system.mutations where table = 'ttl' and is_done;
select '=============';
@ -103,7 +122,8 @@ drop table if exists ttl;
-- Nothing changed, don't run mutation
create table ttl (i Int, s String ttl toDate('2000-01-02')) engine = MergeTree order by i
SETTINGS merge_with_ttl_timeout=0,max_number_of_merges_with_ttl_in_pool=0;
SETTINGS merge_with_ttl_timeout=0;
SYSTEM STOP TTL MERGES;
alter table ttl modify column s String ttl toDate('2000-01-02');
select count() from system.mutations where table = 'ttl' and is_done;

View File

@ -3,22 +3,26 @@ set mutations_sync = 2;
-- check that ttl info was updated after mutation.
create table ttl (i Int, a Int, s String) engine = MergeTree order by i
SETTINGS merge_with_ttl_timeout=0,max_number_of_merges_with_ttl_in_pool=0;
SETTINGS merge_with_ttl_timeout=0;
SYSTEM STOP TTL MERGES;
insert into ttl values (1, 1, 'a') (2, 1, 'b') (3, 1, 'c') (4, 1, 'd');
alter table ttl modify ttl a % 2 = 0 ? today() - 10 : toDate('2100-01-01');
alter table ttl materialize ttl;
select * from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 1;
SYSTEM START TTL MERGES;
optimize table ttl;
SYSTEM STOP TTL MERGES;
select * from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 0;
alter table ttl update a = 0 where i % 2 = 0;
select * from ttl order by i;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 1;
SYSTEM START TTL MERGES;
optimize table ttl;
SYSTEM STOP TTL MERGES;
select * from ttl order by i;
drop table ttl;
@ -28,7 +32,8 @@ select '===================';
-- check that skip index is updated after column was modified by ttl.
create table ttl (i Int, a Int, s String default 'b' ttl a % 2 = 0 ? today() - 10 : toDate('2100-01-01'),
index ind_s (s) type set(1) granularity 1) engine = MergeTree order by i
SETTINGS merge_with_ttl_timeout=0,max_number_of_merges_with_ttl_in_pool=0;
SETTINGS merge_with_ttl_timeout=0;
SYSTEM STOP TTL MERGES;
insert into ttl values (1, 1, 'a') (2, 1, 'a') (3, 1, 'a') (4, 1, 'a');
@ -37,8 +42,10 @@ select count() from ttl where s = 'a';
alter table ttl update a = 0 where i % 2 = 0;
select count() from ttl where s = 'a';
select count() from ttl where s = 'b';
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 1;
SYSTEM START TTL MERGES;
optimize table ttl;
SYSTEM STOP TTL MERGES;
select count() from ttl where s = 'a';
select count() from ttl where s = 'b';
@ -46,19 +53,22 @@ drop table ttl;
-- check only that it doesn't throw exceptions.
create table ttl (i Int, s String) engine = MergeTree order by i ttl toDate('2000-01-01') TO DISK 'default'
SETTINGS merge_with_ttl_timeout=0,max_number_of_merges_with_ttl_in_pool=0;
SETTINGS merge_with_ttl_timeout=0;
SYSTEM STOP TTL MERGES;
alter table ttl materialize ttl;
drop table ttl;
create table ttl (a Int, b Int, c Int default 42 ttl d, d Date, index ind (b * c) type minmax granularity 1)
engine = MergeTree order by a SETTINGS merge_with_ttl_timeout=0,max_number_of_merges_with_ttl_in_pool=0;
engine = MergeTree order by a SETTINGS merge_with_ttl_timeout=0;
SYSTEM STOP TTL MERGES;
insert into ttl values (1, 2, 3, '2100-01-01');
alter table ttl update d = '2000-01-01' where 1;
alter table ttl materialize ttl;
select * from ttl;
alter table ttl modify setting max_number_of_merges_with_ttl_in_pool = 1;
SYSTEM START TTL MERGES;
optimize table ttl;
select * from ttl;
drop table ttl;

View File

@ -1,4 +1,7 @@
DROP TABLE IF EXISTS table_rename_with_ttl;
SET replication_alter_partitions_sync = 2;
SET mutations_sync = 2;
SET materialize_ttl_after_modify = 0;
CREATE TABLE table_rename_with_ttl
(
@ -13,14 +16,13 @@ INSERT INTO table_rename_with_ttl SELECT toDate('2018-10-01') + number % 3, toSt
SELECT count() FROM table_rename_with_ttl;
SET materialize_ttl_after_modify = 0;
ALTER TABLE table_rename_with_ttl MODIFY TTL date1 + INTERVAL 1 MONTH;
SELECT count() FROM table_rename_with_ttl;
ALTER TABLE table_rename_with_ttl RENAME COLUMN date1 TO renamed_date1;
ALTER TABLE table_rename_with_ttl materialize TTL settings mutations_sync=2;
ALTER TABLE table_rename_with_ttl materialize TTL;
SELECT count() FROM table_rename_with_ttl;