Backport #71556 to 24.10: Fix compatibility with refreshable materialized views created by old clickhouse servers

This commit is contained in:
robot-clickhouse 2024-11-07 22:08:39 +00:00
parent b3f043cafd
commit c8b606895d

View File

@ -228,10 +228,20 @@ StorageMaterializedView::StorageMaterializedView(
if (!fixed_uuid) if (!fixed_uuid)
{ {
if (to_inner_uuid != UUIDHelpers::Nil) if (mode >= LoadingStrictnessLevel::ATTACH)
throw Exception(ErrorCodes::BAD_ARGUMENTS, "TO INNER UUID is not allowed for materialized views with REFRESH without APPEND"); {
if (to_table_id.hasUUID()) /// Old versions of ClickHouse (when refreshable MV was experimental) could add useless
throw Exception(ErrorCodes::BAD_ARGUMENTS, "explicit UUID is not allowed for target table of materialized view with REFRESH without APPEND"); /// UUIDs to attach queries.
to_table_id.uuid = UUIDHelpers::Nil;
to_inner_uuid = UUIDHelpers::Nil;
}
else
{
if (to_inner_uuid != UUIDHelpers::Nil)
throw Exception(ErrorCodes::BAD_ARGUMENTS, "TO INNER UUID is not allowed for materialized views with REFRESH without APPEND");
if (to_table_id.hasUUID())
throw Exception(ErrorCodes::BAD_ARGUMENTS, "explicit UUID is not allowed for target table of materialized view with REFRESH without APPEND");
}
} }
if (!has_inner_table) if (!has_inner_table)