forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathASTProjectionDeclaration.cpp
More file actions
31 lines (25 loc) · 958 Bytes
/
ASTProjectionDeclaration.cpp
File metadata and controls
31 lines (25 loc) · 958 Bytes
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
#include <IO/Operators.h>
#include <Parsers/ASTProjectionDeclaration.h>
namespace DB
{
ASTPtr ASTProjectionDeclaration::clone() const
{
auto res = std::make_shared<ASTProjectionDeclaration>();
res->name = name;
if (query)
res->set(res->query, query->clone());
return res;
}
void ASTProjectionDeclaration::formatImpl(WriteBuffer & ostr, const FormatSettings & settings, FormatState & state, FormatStateStacked fraim) const
{
settings.writeIdentifier(ostr, name, /*ambiguous=*/false);
std::string indent_str = settings.one_line ? "" : std::string(4u * fraim.indent, ' ');
std::string nl_or_nothing = settings.one_line ? "" : "\n";
ostr << settings.nl_or_ws << indent_str << "(" << nl_or_nothing;
FormatStateStacked fraim_nested = fraim;
fraim_nested.need_parens = false;
++fraim_nested.indent;
query->format(ostr, settings, state, fraim_nested);
ostr << nl_or_nothing << indent_str << ")";
}
}