Skip to content

Commit 679abff

Browse files
authored
Merge pull request ClickHouse#93016 from Avogar/fix-sparse-mutation
Fix possible error FILE_DOESNT_EXIST after sparse column mutation
2 parents 95e809a + a59f6ed commit 679abff

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/Storages/MergeTree/MutateTask.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,12 +443,20 @@ static void splitAndModifyMutationCommands(
443443
|| command.type == MutationCommand::Type::MATERIALIZE_TTL
444444
|| command.type == MutationCommand::Type::REWRITE_PARTS
445445
|| command.type == MutationCommand::Type::DELETE
446-
|| command.type == MutationCommand::Type::UPDATE
447446
|| command.type == MutationCommand::Type::APPLY_DELETED_MASK
448447
|| command.type == MutationCommand::Type::APPLY_PATCHES)
449448
{
450449
for_interpreter.push_back(command);
451450
}
451+
else if (command.type == MutationCommand::Type::UPDATE)
452+
{
453+
for_interpreter.push_back(command);
454+
455+
/// Update column can change the set of substreams for column if it
456+
/// changes serialization (for example from Sparse to not Sparse).
457+
/// We add it "for renames" because these set of commands also removes redundant files
458+
for_file_renames.push_back(command);
459+
}
452460
else if (command.type == MutationCommand::Type::DROP_INDEX
453461
|| command.type == MutationCommand::Type::DROP_PROJECTION
454462
|| command.type == MutationCommand::Type::DROP_STATISTICS)
@@ -1060,7 +1068,7 @@ static NameToNameVector collectFilesForRenames(
10601068
add_rename(*filename, new_filename);
10611069
}
10621070
}
1063-
else if (command.type == MutationCommand::Type::READ_COLUMN || command.type == MutationCommand::Type::MATERIALIZE_COLUMN)
1071+
else if (command.type == MutationCommand::Type::UPDATE || command.type == MutationCommand::Type::READ_COLUMN || command.type == MutationCommand::Type::MATERIALIZE_COLUMN)
10641072
{
10651073
/// Remove files for streams that exist in source_part,
10661074
/// but were removed in new_part by MODIFY COLUMN or MATERIALIZE COLUMN from
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
0 0
2+
1 0
3+
2 0
4+
3 0
5+
4 0
6+
5 0
7+
6 0
8+
7 0
9+
8 0
10+
9 0
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
drop table if exists test;
2+
create table test (a UInt32, b UInt32) engine=MergeTree order by tuple() settings min_bytes_for_wide_part=0, ratio_of_defaults_for_sparse_serialization=0.0, max_suspicious_broken_parts=0, max_suspicious_broken_parts_bytes=0;
3+
insert into test select number, number from numbers(10);
4+
alter table test modify setting ratio_of_defaults_for_sparse_serialization=1.0;
5+
alter table test update b = 0 where 1 settings mutations_sync=2;
6+
detach table test;
7+
attach table test;
8+
select * from test;
9+

0 commit comments

Comments
 (0)