Merge pull request #9779 from ClickHouse/fix_alters_on_mutations_for_compact_parts

Fix alter drop column for compact parts
This commit is contained in:
alexey-milovidov 2020-03-20 21:31:44 +03:00 committed by GitHub
commit 557ed68e77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 1 deletions

View File

@ -1043,7 +1043,7 @@ MergeTreeData::MutableDataPartPtr MergeTreeDataMergerMutator::mutatePartToTempor
need_remove_expired_values = true;
/// All columns from part are changed and may be some more that were missing before in part
if (source_part->getColumns().isSubsetOf(updated_header.getNamesAndTypesList()))
if (isCompactPart(source_part) || source_part->getColumns().isSubsetOf(updated_header.getNamesAndTypesList()))
{
/// All columns are modified, proceed to write a new part from scratch.
if (data.hasPrimaryKey() || data.hasSkipIndices())

View File

@ -1,4 +1,5 @@
drop table if exists mt_compact;
drop table if exists mt_compact_2;
create table mt_compact (a Int, s String) engine = MergeTree order by a partition by a
settings index_granularity_bytes = 0;
@ -11,6 +12,7 @@ insert into mt_compact_2 values (1, 'a');
alter table mt_compact attach partition 1 from mt_compact_2; -- { serverError 36 }
drop table mt_compact;
drop table mt_compact_2;
set send_logs_level = 'error';
create table mt_compact (a Int, s String) engine = MergeTree order by a partition by a

View File

@ -0,0 +1,22 @@
0 0 1167657 [0,0,0] ['qwqw'] baz
0 0 645645 [1,2] ['qwqw'] 0
0 0 804292 [1,2] ['qwqw'] 3
1 1 1409675 [1,2] ['qwqw'] 1
1 1 1568322 [1,2] ['qwqw'] 4
1 1 2072334 [0,0,0] ['qwqw'] bar
2 4 40262 [1,2] ['qwqw'] 2
2 4 843568 [0,0,0] ['qwqw'] baz
3 9 1748245 [0,0,0] ['qwqw'] bar
4 16 519479 [0,0,0] ['qwqw'] baz
=====================
2 42 40262 [1,2] ['qwqw'] 2
2 42 843568 [0,0,0] ['qwqw'] baz
3 42 1748245 [0,0,0] ['qwqw'] bar
4 42 519479 [0,0,0] ['qwqw'] baz
5 42 1424156 [0,0,0] ['qwqw'] bar
6 42 195390 [0,0,0] ['qwqw'] baz
7 42 1100067 [0,0,0] ['qwqw'] bar
8 42 2004744 [0,0,0] ['qwqw'] baz
9 42 775978 [0,0,0] ['qwqw'] bar
10 42 1680655 [0,0,0] ['qwqw'] baz
=====================

View File

@ -0,0 +1,25 @@
-- Testing basic functionality with compact parts
set replication_alter_partitions_sync = 2;
drop table if exists mt_compact;
create table mt_compact(a UInt64, b UInt64 DEFAULT a * a, s String, n Nested(x UInt32, y String), lc LowCardinality(String))
engine = ReplicatedMergeTree('/clickhouse/test/mt_compact_replicated', '1')
order by a partition by a % 10
settings index_granularity = 8,
min_rows_for_wide_part = 10;
insert into mt_compact (a, s, n.y, lc) select number, toString((number * 2132214234 + 5434543) % 2133443), ['a', 'b', 'c'], number % 2 ? 'bar' : 'baz' from numbers(90);
insert into mt_compact (a, s, n.x, lc) select number % 3, toString((number * 75434535 + 645645) % 2133443), [1, 2], toString(number) from numbers(5);
alter table mt_compact drop column n.y;
alter table mt_compact add column n.y Array(String) DEFAULT ['qwqw'] after n.x;
select * from mt_compact order by a, s limit 10;
select '=====================';
alter table mt_compact update b = 42 where 1 SETTINGS mutations_sync = 2;
select * from mt_compact where a > 1 order by a, s limit 10;
select '=====================';
drop table if exists mt_compact;