mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
add test for mutations with TTL
This commit is contained in:
parent
b0f7905567
commit
803d9da496
@ -425,6 +425,13 @@ ASTPtr MutationsInterpreter::prepare(bool dry_run)
|
||||
if (dependency.kind == ColumnDependency::SKIP_INDEX)
|
||||
dependencies.insert(dependency);
|
||||
}
|
||||
|
||||
if (dependencies.empty())
|
||||
{
|
||||
/// Very rare case. It can happen if we have only one MOVE TTL with constant expression.
|
||||
/// But we still have to read at least one column.
|
||||
dependencies.emplace(all_columns.front().name, ColumnDependency::TTL_EXPRESSION);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1167,7 +1167,7 @@ MergeTreeData::MutableDataPartPtr MergeTreeDataMergerMutator::mutatePartToTempor
|
||||
new_data_part->checksums = source_part->checksums;
|
||||
new_data_part->checksums.add(std::move(changed_checksums));
|
||||
|
||||
if (need_remove_expired_values && !new_data_part->ttl_infos.empty())
|
||||
if (need_remove_expired_values)
|
||||
{
|
||||
/// Write a file with ttl infos in json format.
|
||||
WriteBufferFromFile out_ttl(new_part_tmp_path + "ttl.txt", 4096);
|
||||
|
@ -0,0 +1,11 @@
|
||||
1 1 a
|
||||
2 1 b
|
||||
3 1 c
|
||||
4 1 d
|
||||
1 1 a
|
||||
3 1 c
|
||||
===================
|
||||
4
|
||||
2
|
||||
2
|
||||
1 2 42 2000-01-01
|
@ -0,0 +1,44 @@
|
||||
drop table if exists ttl;
|
||||
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;
|
||||
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 update a = 0 where i % 2 = 0;
|
||||
select * from ttl order by i;
|
||||
|
||||
drop table ttl;
|
||||
|
||||
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;
|
||||
insert into ttl values (1, 1, 'a') (2, 1, 'a') (3, 1, 'a') (4, 1, 'a');
|
||||
|
||||
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';
|
||||
|
||||
drop table ttl;
|
||||
|
||||
-- check only that it doesn't throws exceptions.
|
||||
create table ttl (i Int, s String) engine = MergeTree order by i ttl toDate('2000-01-01') TO DISK 'default';
|
||||
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;
|
||||
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;
|
||||
drop table ttl;
|
Loading…
Reference in New Issue
Block a user