| 1 | #pragma once | 
|---|
| 2 |  | 
|---|
| 3 | #include <Core/Field.h> | 
|---|
| 4 | #include <Core/Types.h> | 
|---|
| 5 | #include <Parsers/IAST.h> | 
|---|
| 6 | #include <Storages/IStorage_fwd.h> | 
|---|
| 7 |  | 
|---|
| 8 | #include <optional> | 
|---|
| 9 | #include <vector> | 
|---|
| 10 |  | 
|---|
| 11 |  | 
|---|
| 12 | namespace DB | 
|---|
| 13 | { | 
|---|
| 14 |  | 
|---|
| 15 | class ASTAlterCommand; | 
|---|
| 16 |  | 
|---|
| 17 | struct PartitionCommand | 
|---|
| 18 | { | 
|---|
| 19 | enum Type | 
|---|
| 20 | { | 
|---|
| 21 | ATTACH_PARTITION, | 
|---|
| 22 | MOVE_PARTITION, | 
|---|
| 23 | CLEAR_COLUMN, | 
|---|
| 24 | CLEAR_INDEX, | 
|---|
| 25 | DROP_PARTITION, | 
|---|
| 26 | DROP_DETACHED_PARTITION, | 
|---|
| 27 | FETCH_PARTITION, | 
|---|
| 28 | FREEZE_ALL_PARTITIONS, | 
|---|
| 29 | FREEZE_PARTITION, | 
|---|
| 30 | REPLACE_PARTITION | 
|---|
| 31 | }; | 
|---|
| 32 |  | 
|---|
| 33 | Type type; | 
|---|
| 34 |  | 
|---|
| 35 | ASTPtr partition; | 
|---|
| 36 | Field column_name; | 
|---|
| 37 | Field index_name; | 
|---|
| 38 |  | 
|---|
| 39 | /// true for DETACH PARTITION. | 
|---|
| 40 | bool detach = false; | 
|---|
| 41 |  | 
|---|
| 42 | /// true for ATTACH PART and DROP DETACHED PART (and false for PARTITION) | 
|---|
| 43 | bool part = false; | 
|---|
| 44 |  | 
|---|
| 45 | /// For ATTACH PARTITION partition FROM db.table | 
|---|
| 46 | String from_database; | 
|---|
| 47 | String from_table; | 
|---|
| 48 | bool replace = true; | 
|---|
| 49 |  | 
|---|
| 50 | /// For FETCH PARTITION - path in ZK to the shard, from which to download the partition. | 
|---|
| 51 | String from_zookeeper_path; | 
|---|
| 52 |  | 
|---|
| 53 | /// For FREEZE PARTITION | 
|---|
| 54 | String with_name; | 
|---|
| 55 |  | 
|---|
| 56 | enum MoveDestinationType | 
|---|
| 57 | { | 
|---|
| 58 | DISK, | 
|---|
| 59 | VOLUME, | 
|---|
| 60 | }; | 
|---|
| 61 |  | 
|---|
| 62 | MoveDestinationType move_destination_type; | 
|---|
| 63 |  | 
|---|
| 64 | String move_destination_name; | 
|---|
| 65 |  | 
|---|
| 66 | static std::optional<PartitionCommand> parse(const ASTAlterCommand * command); | 
|---|
| 67 | }; | 
|---|
| 68 |  | 
|---|
| 69 | class PartitionCommands : public std::vector<PartitionCommand> | 
|---|
| 70 | { | 
|---|
| 71 | public: | 
|---|
| 72 | void validate(const IStorage & table); | 
|---|
| 73 | }; | 
|---|
| 74 |  | 
|---|
| 75 |  | 
|---|
| 76 | } | 
|---|
| 77 |  | 
|---|