optimize deduplicate for tables with projections is not supported

This commit is contained in:
Yakov Olkhovskiy 2024-06-27 23:15:15 +00:00
parent e74ab64b0c
commit 1402a00c8c
5 changed files with 15 additions and 7 deletions

View File

@ -818,11 +818,6 @@ bool MergeTask::MergeProjectionsStage::mergeMinMaxIndexAndPrepareProjections() c
// projection_future_part->path = global_ctx->future_part->path + "/" + projection.name + ".proj/";
projection_future_part->part_info = {"all", 0, 0, 0};
Names deduplicate_by_columns;
for (const auto & column : global_ctx->deduplicate_by_columns)
if (projection.metadata->getColumns().has(column))
deduplicate_by_columns.emplace_back(column);
MergeTreeData::MergingParams projection_merging_params;
projection_merging_params.mode = MergeTreeData::MergingParams::Ordinary;
if (projection.type == ProjectionDescription::Type::Aggregate)
@ -837,7 +832,7 @@ bool MergeTask::MergeProjectionsStage::mergeMinMaxIndexAndPrepareProjections() c
global_ctx->context,
global_ctx->space_reservation,
global_ctx->deduplicate,
deduplicate_by_columns,
global_ctx->deduplicate_by_columns,
global_ctx->cleanup,
projection_merging_params,
global_ctx->need_prefix,

View File

@ -1549,6 +1549,12 @@ bool StorageMergeTree::optimize(
{
assertNotReadonly();
if (deduplicate && getInMemoryMetadataPtr()->hasProjections())
throw Exception(ErrorCodes::NOT_IMPLEMENTED,
"OPTIMIZE DEDUPLICATE query is not supported for table {} as it has projections. "
"User should drop all the projections manually before running the query",
getStorageID().getTableName());
if (deduplicate)
{
if (deduplicate_by_columns.empty())

View File

@ -5746,6 +5746,12 @@ bool StorageReplicatedMergeTree::optimize(
if (!is_leader)
throw Exception(ErrorCodes::NOT_A_LEADER, "OPTIMIZE cannot be done on this replica because it is not a leader");
if (deduplicate && getInMemoryMetadataPtr()->hasProjections())
throw Exception(ErrorCodes::NOT_IMPLEMENTED,
"OPTIMIZE DEDUPLICATE query is not supported for table {} as it has projections. "
"User should drop all the projections manually before running the query",
getStorageID().getTableName());
if (cleanup)
{
if (!getSettings()->allow_experimental_replacing_merge_with_cleanup)

View File

@ -17,7 +17,7 @@ PRIMARY KEY id;
INSERT INTO test_projection_deduplicate VALUES (1, 'one');
INSERT INTO test_projection_deduplicate VALUES (1, 'one');
OPTIMIZE TABLE test_projection_deduplicate DEDUPLICATE;
OPTIMIZE TABLE test_projection_deduplicate DEDUPLICATE; -- { serverError NOT_IMPLEMENTED }
SELECT * FROM test_projection_deduplicate;