ClickHouse/tests/queries/0_stateless/01710_projection_fetch_long.sql

44 lines
2.0 KiB
MySQL
Raw Normal View History

2021-09-12 12:35:27 +00:00
-- Tags: long
2021-05-11 11:44:59 +00:00
drop table if exists tp_1;
drop table if exists tp_2;
2021-06-01 10:24:06 +00:00
create table tp_1 (x Int32, y Int32, projection p (select x, y order by x)) engine = ReplicatedMergeTree('/clickhouse/tables/{shard}/01710_projection_fetch_' || currentDatabase(), '1_{replica}') order by y settings min_rows_for_compact_part = 2, min_rows_for_wide_part = 4, min_bytes_for_compact_part = 16, min_bytes_for_wide_part = 32;
2021-05-11 11:44:59 +00:00
2021-06-01 10:24:06 +00:00
create table tp_2 (x Int32, y Int32, projection p (select x, y order by x)) engine = ReplicatedMergeTree('/clickhouse/tables/{shard}/01710_projection_fetch_' || currentDatabase(), '2_{replica}') order by y settings min_rows_for_compact_part = 2, min_rows_for_wide_part = 4, min_bytes_for_compact_part = 16, min_bytes_for_wide_part = 32;
2021-05-11 11:44:59 +00:00
insert into tp_1 select number, number from numbers(3);
system sync replica tp_2;
select * from tp_2 order by x;
insert into tp_1 select number, number from numbers(5);
system sync replica tp_2;
select * from tp_2 order by x;
-- test projection creation, materialization, clear and drop
alter table tp_1 add projection pp (select x, count() group by x);
system sync replica tp_2;
2021-08-06 04:49:45 +00:00
select count() from system.projection_parts where database = currentDatabase() and table = 'tp_2' and name = 'pp' and active;
show create table tp_2;
-- all other three operations are mutations
set mutations_sync = 2;
alter table tp_1 materialize projection pp;
2021-08-06 04:49:45 +00:00
select count() from system.projection_parts where database = currentDatabase() and table = 'tp_2' and name = 'pp' and active;
show create table tp_2;
alter table tp_1 clear projection pp;
2021-05-19 10:46:09 +00:00
system sync replica tp_2;
2021-08-06 04:49:45 +00:00
select * from system.projection_parts where database = currentDatabase() and table = 'tp_2' and name = 'pp' and active;
show create table tp_2;
alter table tp_1 drop projection pp;
2021-05-16 10:48:07 +00:00
system sync replica tp_2;
2021-08-06 04:49:45 +00:00
select * from system.projection_parts where database = currentDatabase() and table = 'tp_2' and name = 'pp' and active;
show create table tp_2;
2021-05-11 11:44:59 +00:00
drop table if exists tp_1;
drop table if exists tp_2;