blob: 2c28e34261056e9671d6809a90b2ea5f5415ce46 (
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
#include <Parsers/ASTFunctionWithKeyValueArguments.h>
#include <Poco/String.h>
#include <Common/SipHash.h>
#include <IO/Operators.h>
namespace DB
{
String ASTPair::getID(char) const
{
return "pair";
}
ASTPtr ASTPair::clone() const
{
auto res = std::make_shared<ASTPair>(*this);
res->children.clear();
res->set(res->second, second->clone());
return res;
}
void ASTPair::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
{
settings.ostr << (settings.hilite ? hilite_keyword : "") << Poco::toUpper(first) << " " << (settings.hilite ? hilite_none : "");
if (second_with_brackets)
settings.ostr << (settings.hilite ? hilite_keyword : "") << "(";
if (!settings.show_secrets && (first == "password"))
{
/// Hide password in the definition of a dictionary:
/// SOURCE(CLICKHOUSE(host 'example01-01-1' port 9000 user 'default' password '[HIDDEN]' db 'default' table 'ids'))
settings.ostr << "'[HIDDEN]'";
}
else
{
second->formatImpl(settings, state, frame);
}
if (second_with_brackets)
settings.ostr << (settings.hilite ? hilite_keyword : "") << ")";
settings.ostr << (settings.hilite ? hilite_none : "");
}
bool ASTPair::hasSecretParts() const
{
return first == "password";
}
void ASTPair::updateTreeHashImpl(SipHash & hash_state) const
{
hash_state.update(first.size());
hash_state.update(first);
hash_state.update(second_with_brackets);
IAST::updateTreeHashImpl(hash_state);
}
String ASTFunctionWithKeyValueArguments::getID(char delim) const
{
return "FunctionWithKeyValueArguments " + (delim + name);
}
ASTPtr ASTFunctionWithKeyValueArguments::clone() const
{
auto res = std::make_shared<ASTFunctionWithKeyValueArguments>(*this);
res->children.clear();
if (elements)
{
res->elements = elements->clone();
res->children.push_back(res->elements);
}
return res;
}
void ASTFunctionWithKeyValueArguments::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
{
settings.ostr << (settings.hilite ? hilite_keyword : "") << Poco::toUpper(name) << (settings.hilite ? hilite_none : "") << (has_brackets ? "(" : "");
elements->formatImpl(settings, state, frame);
settings.ostr << (has_brackets ? ")" : "");
settings.ostr << (settings.hilite ? hilite_none : "");
}
void ASTFunctionWithKeyValueArguments::updateTreeHashImpl(SipHash & hash_state) const
{
hash_state.update(name.size());
hash_state.update(name);
hash_state.update(has_brackets);
IAST::updateTreeHashImpl(hash_state);
}
}
|