1#pragma once
2
3#include <Parsers/IAST.h>
4#include <Storages/MergeTree/MergeTreeDataFormatVersion.h>
5#include <Core/Types.h>
6
7namespace DB
8{
9
10class MergeTreeData;
11class WriteBuffer;
12class ReadBuffer;
13
14/** The basic parameters of ReplicatedMergeTree table engine for saving in ZooKeeper.
15 * Lets you verify that they match local ones.
16 */
17struct ReplicatedMergeTreeTableMetadata
18{
19 String date_column;
20 String sampling_expression;
21 UInt64 index_granularity;
22 int merging_params_mode;
23 String sign_column;
24 String primary_key;
25 MergeTreeDataFormatVersion data_format_version;
26 String partition_key;
27 String sorting_key;
28 String skip_indices;
29 String constraints;
30 String ttl_table;
31 String ttl_move;
32 UInt64 index_granularity_bytes;
33
34 ReplicatedMergeTreeTableMetadata() = default;
35 explicit ReplicatedMergeTreeTableMetadata(const MergeTreeData & data);
36
37 void read(ReadBuffer & in);
38 static ReplicatedMergeTreeTableMetadata parse(const String & s);
39
40 void write(WriteBuffer & out) const;
41 String toString() const;
42
43 struct Diff
44 {
45 bool sorting_key_changed = false;
46 String new_sorting_key;
47
48 bool skip_indices_changed = false;
49 String new_skip_indices;
50
51 bool constraints_changed = false;
52 String new_constraints;
53
54 bool ttl_table_changed = false;
55 String new_ttl_table;
56
57 bool ttl_move_changed = false;
58 String new_ttl_move;
59
60 bool empty() const
61 {
62 return !sorting_key_changed && !skip_indices_changed && !ttl_table_changed && !constraints_changed && !ttl_move_changed;
63 }
64 };
65
66 Diff checkAndFindDiff(const ReplicatedMergeTreeTableMetadata & from_zk, bool allow_alter) const;
67
68private:
69 bool index_granularity_bytes_found_in_zk = false;
70};
71
72}
73