Merge pull request #71629 from ClickHouse/backport/24.10/71556

Backport #71556 to 24.10: Fix compatibility with refreshable materialized views created by old clickhouse servers
This commit is contained in:
robot-ch-test-poll3 2024-11-08 01:08:47 +01:00 committed by GitHub
commit bab90c1c39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -228,10 +228,20 @@ StorageMaterializedView::StorageMaterializedView(
if (!fixed_uuid)
{
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 (mode >= LoadingStrictnessLevel::ATTACH)
{
/// Old versions of ClickHouse (when refreshable MV was experimental) could add useless
/// 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)