1#include <Parsers/ASTFunctionWithKeyValueArguments.h>
2
3#include <Poco/String.h>
4
5namespace DB
6{
7
8String ASTPair::getID(char) const
9{
10 return "pair";
11}
12
13
14ASTPtr ASTPair::clone() const
15{
16 auto res = std::make_shared<ASTPair>(*this);
17 res->children.clear();
18
19 if (second)
20 {
21 res->second = second;
22 res->children.push_back(second);
23 }
24
25 return res;
26}
27
28
29void ASTPair::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
30{
31 settings.ostr << (settings.hilite ? hilite_keyword : "") << Poco::toUpper(first) << " " << (settings.hilite ? hilite_none : "");
32
33 if (second_with_brackets)
34 settings.ostr << (settings.hilite ? hilite_keyword : "") << "(";
35
36 second->formatImpl(settings, state, frame);
37
38 if (second_with_brackets)
39 settings.ostr << (settings.hilite ? hilite_keyword : "") << ")";
40
41 settings.ostr << (settings.hilite ? hilite_none : "");
42}
43
44String ASTFunctionWithKeyValueArguments::getID(char delim) const
45{
46 return "FunctionWithKeyValueArguments " + (delim + name);
47}
48
49
50ASTPtr ASTFunctionWithKeyValueArguments::clone() const
51{
52 auto res = std::make_shared<ASTFunctionWithKeyValueArguments>(*this);
53 res->children.clear();
54
55 if (elements)
56 {
57 res->elements->clone();
58 res->children.push_back(res->elements);
59 }
60
61 return res;
62}
63
64
65void ASTFunctionWithKeyValueArguments::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
66{
67 settings.ostr << (settings.hilite ? hilite_keyword : "") << Poco::toUpper(name) << (settings.hilite ? hilite_none : "") << "(";
68 elements->formatImpl(settings, state, frame);
69 settings.ostr << ")";
70 settings.ostr << (settings.hilite ? hilite_none : "");
71}
72
73}
74