mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Fix add projection to replicated mergetree
This commit is contained in:
parent
093b7e120a
commit
e5cd597111
@ -4673,6 +4673,10 @@ void StorageReplicatedMergeTree::alter(
|
||||
if (new_indices_str != current_metadata->secondary_indices.toString())
|
||||
future_metadata_in_zk.skip_indices = new_indices_str;
|
||||
|
||||
String new_projections_str = future_metadata.projections.toString();
|
||||
if (new_projections_str != current_metadata->projections.toString())
|
||||
future_metadata_in_zk.projections = new_projections_str;
|
||||
|
||||
String new_constraints_str = future_metadata.constraints.toString();
|
||||
if (new_constraints_str != current_metadata->constraints.toString())
|
||||
future_metadata_in_zk.constraints = new_constraints_str;
|
||||
|
@ -9,3 +9,11 @@
|
||||
2 2
|
||||
3 3
|
||||
4 4
|
||||
0
|
||||
CREATE TABLE default.tp_2\n(\n `x` Int32,\n `y` Int32,\n PROJECTION p\n (\n SELECT \n x,\n y\n ORDER BY x\n ),\n PROJECTION pp\n (\n SELECT \n x,\n count()\n GROUP BY x\n )\n)\nENGINE = ReplicatedMergeTree(\'/clickhouse/tables/01710_projection_fetch_default\', \'2\')\nORDER BY y\nSETTINGS min_rows_for_compact_part = 2, min_rows_for_wide_part = 4, min_bytes_for_compact_part = 16, min_bytes_for_wide_part = 32, index_granularity = 8192
|
||||
2
|
||||
CREATE TABLE default.tp_2\n(\n `x` Int32,\n `y` Int32,\n PROJECTION p\n (\n SELECT \n x,\n y\n ORDER BY x\n ),\n PROJECTION pp\n (\n SELECT \n x,\n count()\n GROUP BY x\n )\n)\nENGINE = ReplicatedMergeTree(\'/clickhouse/tables/01710_projection_fetch_default\', \'2\')\nORDER BY y\nSETTINGS min_rows_for_compact_part = 2, min_rows_for_wide_part = 4, min_bytes_for_compact_part = 16, min_bytes_for_wide_part = 32, index_granularity = 8192
|
||||
0
|
||||
CREATE TABLE default.tp_2\n(\n `x` Int32,\n `y` Int32,\n PROJECTION p\n (\n SELECT \n x,\n y\n ORDER BY x\n ),\n PROJECTION pp\n (\n SELECT \n x,\n count()\n GROUP BY x\n )\n)\nENGINE = ReplicatedMergeTree(\'/clickhouse/tables/01710_projection_fetch_default\', \'2\')\nORDER BY y\nSETTINGS min_rows_for_compact_part = 2, min_rows_for_wide_part = 4, min_bytes_for_compact_part = 16, min_bytes_for_wide_part = 32, index_granularity = 8192
|
||||
0
|
||||
CREATE TABLE default.tp_2\n(\n `x` Int32,\n `y` Int32,\n PROJECTION p\n (\n SELECT \n x,\n y\n ORDER BY x\n )\n)\nENGINE = ReplicatedMergeTree(\'/clickhouse/tables/01710_projection_fetch_default\', \'2\')\nORDER BY y\nSETTINGS min_rows_for_compact_part = 2, min_rows_for_wide_part = 4, min_bytes_for_compact_part = 16, min_bytes_for_wide_part = 32, index_granularity = 8192
|
||||
|
@ -15,6 +15,26 @@ 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;
|
||||
select count() from system.projection_parts where 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;
|
||||
select count() from system.projection_parts where table = 'tp_2' and name = 'pp' and active;
|
||||
show create table tp_2;
|
||||
|
||||
alter table tp_1 clear projection pp;
|
||||
select count() from system.projection_parts where table = 'tp_2' and name = 'pp' and active;
|
||||
show create table tp_2;
|
||||
|
||||
alter table tp_1 drop projection pp;
|
||||
select count() from system.projection_parts where table = 'tp_2' and name = 'pp' and active;
|
||||
show create table tp_2;
|
||||
|
||||
drop table if exists tp_1;
|
||||
drop table if exists tp_2;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user