2021-11-26 18:27:16 +00:00
|
|
|
#include <IO/Operators.h>
|
2021-02-10 14:12:49 +00:00
|
|
|
#include <Parsers/ASTProjectionDeclaration.h>
|
|
|
|
#include <Common/quoteString.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2021-06-02 15:09:55 +00:00
|
|
|
|
2021-02-10 14:12:49 +00:00
|
|
|
ASTPtr ASTProjectionDeclaration::clone() const
|
|
|
|
{
|
2021-06-02 15:09:55 +00:00
|
|
|
auto res = std::make_shared<ASTProjectionDeclaration>();
|
|
|
|
res->name = name;
|
|
|
|
if (query)
|
|
|
|
res->set(res->query, query->clone());
|
|
|
|
return res;
|
2021-02-10 14:12:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ASTProjectionDeclaration::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
|
|
|
|
{
|
|
|
|
settings.ostr << backQuoteIfNeed(name);
|
|
|
|
std::string indent_str = settings.one_line ? "" : std::string(4u * frame.indent, ' ');
|
|
|
|
std::string nl_or_nothing = settings.one_line ? "" : "\n";
|
2022-02-07 02:47:11 +00:00
|
|
|
settings.ostr << settings.nl_or_ws << indent_str << "(" << nl_or_nothing;
|
2021-02-10 14:12:49 +00:00
|
|
|
FormatStateStacked frame_nested = frame;
|
|
|
|
frame_nested.need_parens = false;
|
|
|
|
++frame_nested.indent;
|
|
|
|
query->formatImpl(settings, state, frame_nested);
|
|
|
|
settings.ostr << nl_or_nothing << indent_str << ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|