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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
#pragma once
#include <Parsers/IAST.h>
#include <Parsers/ASTFunctionWithKeyValueArguments.h>
#include <Parsers/ASTExpressionList.h>
#include <Parsers/ASTSetQuery.h>
#include <Parsers/ParserSetQuery.h>
namespace DB
{
class ASTLiteral;
/// AST for external dictionary lifetime:
/// lifetime(min 10 max 100)
class ASTDictionaryLifetime : public IAST
{
public:
UInt64 min_sec = 0;
UInt64 max_sec = 0;
String getID(char) const override { return "Dictionary lifetime"; }
ASTPtr clone() const override;
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
};
/// AST for external dictionary layout. Has name and contain single parameter
/// layout(type()) or layout(type(param value))
class ASTDictionaryLayout : public IAST
{
using KeyValue = std::pair<std::string, ASTLiteral *>;
public:
/// flat, cache, hashed, etc.
String layout_type;
/// parameters (size_in_cells, ...)
/// ASTExpressionList -> ASTPair -> (ASTLiteral key, ASTLiteral value).
ASTExpressionList * parameters;
/// has brackets after layout type
bool has_brackets = true;
String getID(char) const override { return "Dictionary layout"; }
ASTPtr clone() const override;
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
void forEachPointerToChild(std::function<void(void**)> f) override
{
f(reinterpret_cast<void **>(¶meters));
}
};
/// AST for external range-hashed dictionary
/// Range bounded with two attributes from minimum to maximum
/// RANGE(min attr1 max attr2)
class ASTDictionaryRange : public IAST
{
public:
String min_attr_name;
String max_attr_name;
String getID(char) const override { return "Dictionary range"; }
ASTPtr clone() const override;
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
};
class ASTDictionarySettings : public IAST
{
public:
SettingsChanges changes;
String getID(char) const override { return "Dictionary settings"; }
ASTPtr clone() const override;
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
};
/// AST contains all parts of external dictionary definition except attributes
class ASTDictionary : public IAST
{
public:
/// Dictionary keys -- one or more
ASTExpressionList * primary_key = nullptr;
/// Dictionary external source, doesn't have own AST, because
/// source parameters absolutely different for different sources
ASTFunctionWithKeyValueArguments * source = nullptr;
/// Lifetime of dictionary (required part)
ASTDictionaryLifetime * lifetime = nullptr;
/// Layout of dictionary (required part)
ASTDictionaryLayout * layout = nullptr;
/// Range for dictionary (only for range-hashed dictionaries)
ASTDictionaryRange * range = nullptr;
/// Settings for dictionary (optionally)
ASTDictionarySettings * dict_settings = nullptr;
String getID(char) const override { return "Dictionary definition"; }
ASTPtr clone() const override;
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
};
}
|