diff --git a/src/Parsers/ASTAlterQuery.h b/src/Parsers/ASTAlterQuery.h index df27ba0a3b0..00350d4efa1 100644 --- a/src/Parsers/ASTAlterQuery.h +++ b/src/Parsers/ASTAlterQuery.h @@ -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(type))); } ASTPtr clone() const override; diff --git a/src/Parsers/ParserAlterQuery.cpp b/src/Parsers/ParserAlterQuery.cpp index 9930bb649b4..b7bde35139b 100644 --- a/src/Parsers/ParserAlterQuery.cpp +++ b/src/Parsers/ParserAlterQuery.cpp @@ -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)) {