Starting steps

This commit is contained in:
alesapin 2020-09-09 15:18:16 +03:00
parent 6dd764bcfe
commit 489b9c80ac
2 changed files with 34 additions and 8 deletions

View File

@ -28,11 +28,13 @@ public:
ADD_COLUMN,
DROP_COLUMN,
MODIFY_COLUMN,
MODIFY_COLUMN_REMOVE_PROPERTY,
COMMENT_COLUMN,
RENAME_COLUMN,
MODIFY_ORDER_BY,
MODIFY_SAMPLE_BY,
MODIFY_TTL,
REMOVE_TABLE_TTL,
MATERIALIZE_TTL,
MODIFY_SETTING,
MODIFY_QUERY,
@ -61,6 +63,20 @@ public:
LIVE_VIEW_REFRESH,
};
/// Which property user wants to remove from column
enum RemoveProperty
{
/// Default specifiers
DEFAULT,
MATERIALIZED,
ALIAS,
/// Other properties
COMMENT,
CODEC,
TTL
};
Type type = NO_TYPE;
/** The ADD COLUMN query stores the name and type of the column to add
@ -167,6 +183,8 @@ public:
/// Target column name
ASTPtr rename_to;
RemoveProperty to_remove;
String getID(char delim) const override { return "AlterCommand" + (delim + std::to_string(static_cast<int>(type))); }
ASTPtr clone() const override;

View File

@ -82,6 +82,8 @@ bool ParserAlterCommand::parseImpl(Pos & pos, ASTPtr & node, Expected & expected
ParserKeyword s_where("WHERE");
ParserKeyword s_to("TO");
ParserKeyword s_remove("REMOVE");
ParserCompoundIdentifier parser_name;
ParserStringLiteral parser_string_literal;
ParserCompoundColumnDeclaration parser_col_decl;
@ -430,18 +432,24 @@ bool ParserAlterCommand::parseImpl(Pos & pos, ASTPtr & node, Expected & expected
if (s_if_exists.ignore(pos, expected))
command->if_exists = true;
if (!parser_modify_col_decl.parse(pos, command->col_decl, expected))
return false;
if (s_first.ignore(pos, expected))
command->first = true;
else if (s_after.ignore(pos, expected))
if (s_remove.ignore(pos, expected))
{
if (!parser_name.parse(pos, command->column, expected))
}
else
{
if (!parser_modify_col_decl.parse(pos, command->col_decl, expected))
return false;
if (s_first.ignore(pos, expected))
command->first = true;
else if (s_after.ignore(pos, expected))
{
if (!parser_name.parse(pos, command->column, expected))
return false;
}
command->type = ASTAlterCommand::MODIFY_COLUMN;
}
command->type = ASTAlterCommand::MODIFY_COLUMN;
}
else if (s_modify_order_by.ignore(pos, expected))
{