Fix detaching parts with projections

This commit is contained in:
Amos Bird 2021-12-01 23:17:31 +08:00
parent 1f9b542ee9
commit 8dbc7a8dae
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4
3 changed files with 17 additions and 3 deletions

View File

@ -1323,9 +1323,7 @@ void IMergeTreeDataPart::renameToDetached(const String & prefix) const
void IMergeTreeDataPart::makeCloneInDetached(const String & prefix, const StorageMetadataPtr & /*metadata_snapshot*/) const
{
String destination_path = fs::path(storage.relative_data_path) / getRelativePathForDetachedPart(prefix);
/// Backup is not recursive (max_level is 0), so do not copy inner directories
localBackup(volume->getDisk(), getFullRelativePath(), destination_path, 0);
localBackup(volume->getDisk(), getFullRelativePath(), destination_path);
volume->getDisk()->removeFileIfExists(fs::path(destination_path) / DELETE_ON_DESTROY_MARKER_FILE_NAME);
}

View File

@ -0,0 +1,15 @@
set allow_experimental_projection_optimization = 1;
drop table if exists t;
create table t (i int, j int, projection x (select * order by j)) engine MergeTree partition by i order by i;
insert into t values (1, 2);
alter table t detach partition 1;
alter table t attach partition 1;
select count() from system.projection_parts where database = currentDatabase() and table = 't';
drop table t;