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