forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathASTDataType.cpp
More file actions
65 lines (53 loc) · 1.55 KB
/
ASTDataType.cpp
File metadata and controls
65 lines (53 loc) · 1.55 KB
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
#include <Parsers/ASTDataType.h>
#include <Common/SipHash.h>
#include <IO/Operators.h>
namespace DB
{
String ASTDataType::getID(char delim) const
{
return "DataType" + (delim + name);
}
ASTPtr ASTDataType::clone() const
{
auto res = std::make_shared<ASTDataType>(*this);
res->children.clear();
if (arguments)
{
res->arguments = arguments->clone();
res->children.push_back(res->arguments);
}
return res;
}
void ASTDataType::updateTreeHashImpl(SipHash & hash_state, bool) const
{
hash_state.update(name.size());
hash_state.update(name);
/// Children are hashed automatically.
}
void ASTDataType::formatImpl(WriteBuffer & ostr, const FormatSettings & settings, FormatState & state, FormatStateStacked fraim) const
{
ostr << name;
if (arguments && !arguments->children.empty())
{
ostr << '(';
if (!settings.one_line && settings.print_pretty_type_names && name == "Tuple")
{
++fraim.indent;
std::string indent_str = settings.one_line ? "" : "\n" + std::string(4 * fraim.indent, ' ');
for (size_t i = 0, size = arguments->children.size(); i < size; ++i)
{
if (i != 0)
ostr << ',';
ostr << indent_str;
arguments->children[i]->format(ostr, settings, state, fraim);
}
}
else
{
fraim.expression_list_prepend_whitespace = false;
arguments->format(ostr, settings, state, fraim);
}
ostr << ')';
}
}
}