#pragma once #include #include #include #include #include #include namespace DB { class Context; class WriteBuffer; class ReadBuffer; /// Represents set of actions which should be applied /// to values from set of columns which statisfy predicate. struct MutationCommand { ASTPtr ast; /// The AST of the whole command enum Type { EMPTY, /// Not used. DELETE, UPDATE, MATERIALIZE_INDEX, READ_COLUMN, DROP_COLUMN, DROP_INDEX, MATERIALIZE_TTL }; Type type = EMPTY; /// WHERE part of mutation ASTPtr predicate; /// Columns with corresponding actions std::unordered_map column_to_update_expression; /// For MATERIALIZE INDEX String index_name; ASTPtr partition; /// For reads, drops and etc. String column_name; DataTypePtr data_type; /// Maybe empty if we just want to drop column /// We need just clear column, not drop from metadata. bool clear = false; /// If parse_alter_commands, than consider more Alter commands as mutation commands static std::optional parse(ASTAlterCommand * command, bool parse_alter_commands = false); }; /// Multiple mutation commands, possible from different ALTER queries class MutationCommands : public std::vector { public: std::shared_ptr ast() const; void writeText(WriteBuffer & out) const; void readText(ReadBuffer & in); }; }