Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix alter drop column for compact parts #9779

Merged
merged 1 commit into from
Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 2 additions & 0 deletions dbms/tests/queries/0_stateless/01055_compact_parts_1.sql
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
=====================
Original file line number Diff line number Diff line change
@@ -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;