ClickHouse/dbms/src/Storages/PartitionCommands.h

82 lines
1.5 KiB
C++
Raw Normal View History

#pragma once
#include <Core/Field.h>
#include <Core/Types.h>
#include <Parsers/IAST.h>
#include <Storages/IStorage_fwd.h>
2018-06-16 02:16:19 +00:00
#include <optional>
#include <vector>
namespace DB
{
class ASTAlterCommand;
struct PartitionCommand
{
enum Type
{
ATTACH_PARTITION,
2019-07-18 15:19:03 +00:00
MOVE_PARTITION,
2018-11-01 10:35:50 +00:00
CLEAR_COLUMN,
2019-05-09 14:25:18 +00:00
CLEAR_INDEX,
2018-11-01 10:35:50 +00:00
DROP_PARTITION,
2019-07-22 11:23:11 +00:00
DROP_DETACHED_PARTITION,
FETCH_PARTITION,
FREEZE_ALL_PARTITIONS,
FREEZE_PARTITION,
2018-11-01 10:35:50 +00:00
REPLACE_PARTITION,
};
Type type;
ASTPtr partition;
Field column_name;
2019-05-09 14:25:18 +00:00
Field index_name;
/// true for DETACH PARTITION.
bool detach = false;
2019-07-22 11:23:11 +00:00
/// true for ATTACH PART and DROP DETACHED PART (and false for PARTITION)
bool part = false;
/// For ATTACH PARTITION partition FROM db.table
String from_database;
String from_table;
bool replace = true;
/// For MOVE PARTITION
String to_database;
String to_table;
2019-07-29 03:14:53 +00:00
/// For FETCH PARTITION - path in ZK to the shard, from which to download the partition.
String from_zookeeper_path;
/// For FREEZE PARTITION
String with_name;
enum MoveDestinationType
2019-07-18 15:19:03 +00:00
{
DISK,
VOLUME,
2019-09-16 07:27:38 +00:00
PARTITION,
2019-07-18 15:19:03 +00:00
};
2019-09-04 13:24:55 +00:00
MoveDestinationType move_destination_type;
2019-07-18 15:19:03 +00:00
String move_destination_name;
2019-07-18 15:19:03 +00:00
static std::optional<PartitionCommand> parse(const ASTAlterCommand * command);
};
class PartitionCommands : public std::vector<PartitionCommand>
{
public:
void validate(const IStorage & table);
};
}