Merge pull request #32067 from amosbird/projection-fix23

Fix detaching parts with projections
This commit is contained in:
Nikolai Kochetov 2021-12-13 12:00:17 +03:00 committed by GitHub
commit 22e6fc1685
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View File

@ -1350,9 +1350,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;