mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-14 18:32:29 +00:00
Merged DROP_(COLUMN|INDEX|CONSTRAINT) AST parsing into one block
This commit is contained in:
parent
bb78012cf9
commit
ea4d42c3ac
@ -74,17 +74,6 @@ std::optional<AlterCommand> AlterCommand::parse(const ASTAlterCommand * command_
|
||||
|
||||
return command;
|
||||
}
|
||||
else if (command_ast->type == ASTAlterCommand::DROP_COLUMN && !command_ast->partition)
|
||||
{
|
||||
if (command_ast->clear_column)
|
||||
throw Exception("\"ALTER TABLE table CLEAR COLUMN column\" queries are not supported yet. Use \"CLEAR COLUMN column IN PARTITION\".", ErrorCodes::NOT_IMPLEMENTED);
|
||||
|
||||
AlterCommand command;
|
||||
command.type = AlterCommand::DROP_COLUMN;
|
||||
command.column_name = *getIdentifierName(command_ast->column);
|
||||
command.if_exists = command_ast->if_exists;
|
||||
return command;
|
||||
}
|
||||
else if (command_ast->type == ASTAlterCommand::MODIFY_COLUMN)
|
||||
{
|
||||
AlterCommand command;
|
||||
@ -154,18 +143,6 @@ std::optional<AlterCommand> AlterCommand::parse(const ASTAlterCommand * command_
|
||||
|
||||
return command;
|
||||
}
|
||||
else if (command_ast->type == ASTAlterCommand::DROP_INDEX)
|
||||
{
|
||||
if (command_ast->clear_column)
|
||||
throw Exception("\"ALTER TABLE table CLEAR COLUMN column\" queries are not supported yet. Use \"CLEAR COLUMN column IN PARTITION\".", ErrorCodes::NOT_IMPLEMENTED);
|
||||
|
||||
AlterCommand command;
|
||||
command.type = AlterCommand::DROP_INDEX;
|
||||
command.index_name = command_ast->index->as<ASTIdentifier &>().name;
|
||||
command.if_exists = command_ast->if_exists;
|
||||
|
||||
return command;
|
||||
}
|
||||
else if (command_ast->type == ASTAlterCommand::ADD_CONSTRAINT)
|
||||
{
|
||||
AlterCommand command;
|
||||
@ -180,15 +157,25 @@ std::optional<AlterCommand> AlterCommand::parse(const ASTAlterCommand * command_
|
||||
|
||||
return command;
|
||||
}
|
||||
else if (command_ast->type == ASTAlterCommand::DROP_CONSTRAINT)
|
||||
else if (command_ast->type == ASTAlterCommand::DROP_CONSTRAINT
|
||||
|| command_ast->type == ASTAlterCommand::DROP_INDEX
|
||||
|| (command_ast->type == ASTAlterCommand::DROP_COLUMN && !command_ast->partition))
|
||||
{
|
||||
if (command_ast->clear_column)
|
||||
throw Exception("\"ALTER TABLE table CLEAR COLUMN column\" queries are not supported yet. Use \"CLEAR COLUMN column IN PARTITION\".", ErrorCodes::NOT_IMPLEMENTED);
|
||||
|
||||
AlterCommand command;
|
||||
command.type = AlterCommand::DROP_CONSTRAINT;
|
||||
command.constraint_name = command_ast->constraint->as<ASTIdentifier &>().name;
|
||||
command.if_exists = command_ast->if_exists;
|
||||
if (command_ast->type == ASTAlterCommand::DROP_INDEX) {
|
||||
command.type = AlterCommand::DROP_INDEX;
|
||||
command.index_name = command_ast->index->as<ASTIdentifier &>().name;
|
||||
} else if (command_ast->type == ASTAlterCommand::DROP_CONSTRAINT) {
|
||||
command.type = AlterCommand::DROP_CONSTRAINT;
|
||||
command.constraint_name = command_ast->constraint->as<ASTIdentifier &>().name;
|
||||
} else if (command_ast->type == ASTAlterCommand::DROP_COLUMN) {
|
||||
command.type = AlterCommand::DROP_COLUMN;
|
||||
command.column_name = *getIdentifierName(command_ast->column);
|
||||
}
|
||||
|
||||
return command;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user