1. Draw some circles.

This commit is contained in:
Vladimir Chebotarev 2021-07-31 21:17:06 +03:00
parent af709ab9a0
commit ce0850007f
10 changed files with 61 additions and 1 deletions

View File

@ -43,6 +43,7 @@ enum class AccessType
M(ALTER_COMMENT_COLUMN, "COMMENT COLUMN", COLUMN, ALTER_COLUMN) \
M(ALTER_CLEAR_COLUMN, "CLEAR COLUMN", COLUMN, ALTER_COLUMN) \
M(ALTER_RENAME_COLUMN, "RENAME COLUMN", COLUMN, ALTER_COLUMN) \
M(ALTER_MATERIALIZE_COLUMN, "MATERIALIZE COLUMN", COLUMN, ALTER_COLUMN) \
M(ALTER_COLUMN, "", GROUP, ALTER_TABLE) /* allow to execute ALTER {ADD|DROP|MODIFY...} COLUMN */\
\
M(ALTER_ORDER_BY, "ALTER MODIFY ORDER BY, MODIFY ORDER BY", TABLE, ALTER_INDEX) \

View File

@ -203,6 +203,11 @@ AccessRightsElements InterpreterAlterQuery::getRequiredAccessForCommand(const AS
required_access.emplace_back(AccessType::ALTER_COMMENT_COLUMN, database, table, column_name());
break;
}
case ASTAlterCommand::MATERIALIZE_COLUMN:
{
required_access.emplace_back(AccessType::ALTER_MATERIALIZE_COLUMN, database, table);
break;
}
case ASTAlterCommand::MODIFY_ORDER_BY:
{
required_access.emplace_back(AccessType::ALTER_ORDER_BY, database, table);

View File

@ -319,7 +319,13 @@ AccessRightsElements InterpreterKillQueryQuery::getRequiredAccessForDDLOnCluster
if (query.type == ASTKillQueryQuery::Type::Query)
required_access.emplace_back(AccessType::KILL_QUERY);
else if (query.type == ASTKillQueryQuery::Type::Mutation)
required_access.emplace_back(AccessType::ALTER_UPDATE | AccessType::ALTER_DELETE | AccessType::ALTER_MATERIALIZE_INDEX | AccessType::ALTER_MATERIALIZE_TTL);
required_access.emplace_back(
AccessType::ALTER_UPDATE
| AccessType::ALTER_DELETE
| AccessType::ALTER_MATERIALIZE_INDEX
| AccessType::ALTER_MATERIALIZE_COLUMN
| AccessType::ALTER_MATERIALIZE_TTL
);
return required_access;
}

View File

@ -543,6 +543,10 @@ ASTPtr MutationsInterpreter::prepare(bool dry_run)
}
}
}
else if (command.type == MutationCommand::MATERIALIZE_COLUMN)
{
/// FIXME
}
else if (command.type == MutationCommand::MATERIALIZE_INDEX)
{
mutation_kind.set(MutationKind::MUTATE_INDEX_PROJECTION);

View File

@ -120,6 +120,17 @@ void ASTAlterCommand::formatImpl(
}
}
}
else if (type == ASTAlterCommand::MATERIALIZE_COLUMN)
{
settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str
<< "MATERIALIZE COLUMN " << (settings.hilite ? hilite_none : "");
column->formatImpl(settings, state, frame);
if (partition)
{
settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << " IN PARTITION " << (settings.hilite ? hilite_none : "");
partition->formatImpl(settings, state, frame);
}
}
else if (type == ASTAlterCommand::COMMENT_COLUMN)
{
settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << "COMMENT COLUMN " << (if_exists ? "IF EXISTS " : "") << (settings.hilite ? hilite_none : "");

View File

@ -31,6 +31,8 @@ public:
MODIFY_COLUMN,
COMMENT_COLUMN,
RENAME_COLUMN,
MATERIALIZE_COLUMN,
MODIFY_ORDER_BY,
MODIFY_SAMPLE_BY,
MODIFY_TTL,

View File

@ -28,6 +28,8 @@ bool ParserAlterCommand::parseImpl(Pos & pos, ASTPtr & node, Expected & expected
ParserKeyword s_modify_column("MODIFY COLUMN");
ParserKeyword s_rename_column("RENAME COLUMN");
ParserKeyword s_comment_column("COMMENT COLUMN");
ParserKeyword s_materialize_column("MATERIALIZE COLUMN");
ParserKeyword s_modify_order_by("MODIFY ORDER BY");
ParserKeyword s_modify_sample_by("MODIFY SAMPLE BY");
ParserKeyword s_modify_ttl("MODIFY TTL");
@ -168,6 +170,20 @@ bool ParserAlterCommand::parseImpl(Pos & pos, ASTPtr & node, Expected & expected
command->type = ASTAlterCommand::RENAME_COLUMN;
}
else if (s_materialize_column.ignore(pos, expected))
{
if (!parser_name.parse(pos, command->column, expected))
return false;
command->type = ASTAlterCommand::MATERIALIZE_COLUMN;
command->detach = false;
if (s_in_partition.ignore(pos, expected))
{
if (!parser_partition.parse(pos, command->partition, expected))
return false;
}
}
else if (s_drop_partition.ignore(pos, expected))
{
if (!parser_partition.parse(pos, command->partition, expected))

View File

@ -1548,6 +1548,7 @@ void MergeTreeDataMergerMutator::splitMutationCommands(
for (const auto & command : commands)
{
if (command.type == MutationCommand::Type::MATERIALIZE_INDEX
|| command.type == MutationCommand::Type::MATERIALIZE_COLUMN
|| command.type == MutationCommand::Type::MATERIALIZE_PROJECTION
|| command.type == MutationCommand::Type::MATERIALIZE_TTL
|| command.type == MutationCommand::Type::DELETE
@ -1556,6 +1557,9 @@ void MergeTreeDataMergerMutator::splitMutationCommands(
for_interpreter.push_back(command);
for (const auto & [column_name, expr] : command.column_to_update_expression)
mutated_columns.emplace(column_name);
if (command.type == MutationCommand::Type::MATERIALIZE_COLUMN)
mutated_columns.emplace(command.column_name);
}
else if (command.type == MutationCommand::Type::DROP_INDEX || command.type == MutationCommand::Type::DROP_PROJECTION)
{
@ -1593,6 +1597,7 @@ void MergeTreeDataMergerMutator::splitMutationCommands(
for (const auto & command : commands)
{
if (command.type == MutationCommand::Type::MATERIALIZE_INDEX
|| command.type == MutationCommand::Type::MATERIALIZE_COLUMN
|| command.type == MutationCommand::Type::MATERIALIZE_PROJECTION
|| command.type == MutationCommand::Type::MATERIALIZE_TTL
|| command.type == MutationCommand::Type::DELETE

View File

@ -75,6 +75,15 @@ std::optional<MutationCommand> MutationCommand::parse(ASTAlterCommand * command,
res.projection_name = command->projection->as<ASTIdentifier &>().name();
return res;
}
else if (command->type == ASTAlterCommand::MATERIALIZE_COLUMN)
{
MutationCommand res;
res.ast = command->ptr();
res.type = MATERIALIZE_COLUMN;
res.partition = command->partition;
res.column_name = getIdentifierName(command->column);
return res;
}
else if (parse_alter_commands && command->type == ASTAlterCommand::MODIFY_COLUMN)
{
MutationCommand res;

View File

@ -35,6 +35,7 @@ struct MutationCommand
DROP_PROJECTION,
MATERIALIZE_TTL,
RENAME_COLUMN,
MATERIALIZE_COLUMN,
};
Type type = EMPTY;