ClickHouse/dbms/src/Storages/MutationCommands.h

51 lines
860 B
C++
Raw Normal View History

#pragma once
#include <Parsers/ASTAlterQuery.h>
#include <optional>
#include <unordered_map>
namespace DB
{
class IStorage;
class Context;
class WriteBuffer;
class ReadBuffer;
struct MutationCommand
{
ASTPtr ast; /// The AST of the whole command
enum Type
{
EMPTY, /// Not used.
DELETE,
UPDATE,
2019-04-10 17:44:39 +00:00
MATERIALIZE_INDEX
};
Type type = EMPTY;
ASTPtr predicate;
std::unordered_map<String, ASTPtr> column_to_update_expression;
2019-04-10 17:44:39 +00:00
/// For MATERIALIZE INDEX
2019-05-05 17:01:54 +00:00
String index_name;
2019-04-10 17:44:39 +00:00
ASTPtr partition;
static std::optional<MutationCommand> parse(ASTAlterCommand * command);
};
class MutationCommands : public std::vector<MutationCommand>
{
public:
std::shared_ptr<ASTAlterCommandList> ast() const;
void writeText(WriteBuffer & out) const;
void readText(ReadBuffer & in);
};
}