diff --git a/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp b/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp index 9911796e2d5..9888f7003f1 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp @@ -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()) diff --git a/dbms/tests/queries/0_stateless/01055_compact_parts_1.sql b/dbms/tests/queries/0_stateless/01055_compact_parts_1.sql index 91941b90860..c2c2ab041e7 100644 --- a/dbms/tests/queries/0_stateless/01055_compact_parts_1.sql +++ b/dbms/tests/queries/0_stateless/01055_compact_parts_1.sql @@ -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 diff --git a/dbms/tests/queries/0_stateless/01201_drop_column_compact_part_replicated.reference b/dbms/tests/queries/0_stateless/01201_drop_column_compact_part_replicated.reference new file mode 100644 index 00000000000..2b02239775d --- /dev/null +++ b/dbms/tests/queries/0_stateless/01201_drop_column_compact_part_replicated.reference @@ -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 +===================== diff --git a/dbms/tests/queries/0_stateless/01201_drop_column_compact_part_replicated.sql b/dbms/tests/queries/0_stateless/01201_drop_column_compact_part_replicated.sql new file mode 100644 index 00000000000..53cf940de6d --- /dev/null +++ b/dbms/tests/queries/0_stateless/01201_drop_column_compact_part_replicated.sql @@ -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;