1#include <Parsers/ASTSelectWithUnionQuery.h>
2#include <Parsers/ASTSelectQuery.h>
3#include <Common/typeid_cast.h>
4
5
6namespace DB
7{
8
9ASTPtr ASTSelectWithUnionQuery::clone() const
10{
11 auto res = std::make_shared<ASTSelectWithUnionQuery>(*this);
12 res->children.clear();
13
14 res->list_of_selects = list_of_selects->clone();
15 res->children.push_back(res->list_of_selects);
16
17 cloneOutputOptions(*res);
18 return res;
19}
20
21
22void ASTSelectWithUnionQuery::formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
23{
24 std::string indent_str = settings.one_line ? "" : std::string(4 * frame.indent, ' ');
25
26 for (ASTs::const_iterator it = list_of_selects->children.begin(); it != list_of_selects->children.end(); ++it)
27 {
28 if (it != list_of_selects->children.begin())
29 settings.ostr
30 << settings.nl_or_ws << indent_str << (settings.hilite ? hilite_keyword : "")
31 << "UNION ALL" << (settings.hilite ? hilite_none : "")
32 << settings.nl_or_ws;
33
34 (*it)->formatImpl(settings, state, frame);
35 }
36}
37
38}
39