Require mutations for DROP COLUMN by root column name for nested columns

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
Azat Khuzhin 2022-03-31 12:50:13 +03:00
parent ca7e4c6eb2
commit 73ddc25e1e
3 changed files with 9 additions and 1 deletions

View File

@ -785,7 +785,7 @@ bool AlterCommand::isRequireMutationStage(const StorageInMemoryMetadata & metada
/// Drop alias is metadata alter, in other case mutation is required.
if (type == DROP_COLUMN)
return metadata.columns.hasPhysical(column_name);
return metadata.columns.hasColumnOrNested(GetColumnsOptions::AllPhysical, column_name);
if (type != MODIFY_COLUMN || data_type == nullptr)
return false;

View File

@ -603,6 +603,13 @@ bool ColumnsDescription::hasColumnOrSubcolumn(GetColumnsOptions::Kind kind, cons
|| hasSubcolumn(column_name);
}
bool ColumnsDescription::hasColumnOrNested(GetColumnsOptions::Kind kind, const String & column_name) const
{
auto range = getNameRange(columns, column_name);
return range.first != range.second &&
defaultKindToGetKind(range.first->default_desc.kind) & kind;
}
bool ColumnsDescription::hasDefaults() const
{
for (const auto & column : columns)

View File

@ -167,6 +167,7 @@ public:
bool hasPhysical(const String & column_name) const;
bool hasColumnOrSubcolumn(GetColumnsOptions::Kind kind, const String & column_name) const;
bool hasColumnOrNested(GetColumnsOptions::Kind kind, const String & column_name) const;
NameAndTypePair getPhysical(const String & column_name) const;
NameAndTypePair getColumnOrSubcolumn(GetColumnsOptions::Kind kind, const String & column_name) const;