2012-08-22 18:46:09 +00:00
|
|
|
#pragma once
|
|
|
|
|
2015-07-26 07:55:48 +00:00
|
|
|
#include <DB/Parsers/ASTWithAlias.h>
|
2012-08-22 18:46:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2014-12-15 20:43:24 +00:00
|
|
|
/** Подзарос SELECT
|
2012-08-22 18:46:09 +00:00
|
|
|
*/
|
2015-07-26 07:55:48 +00:00
|
|
|
class ASTSubquery : public ASTWithAlias
|
2012-08-22 18:46:09 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-12-15 20:43:24 +00:00
|
|
|
ASTSubquery() = default;
|
2015-07-26 07:55:48 +00:00
|
|
|
ASTSubquery(const StringRange range_) : ASTWithAlias(range_) {}
|
|
|
|
|
2012-08-22 18:46:09 +00:00
|
|
|
/** Получить текст, который идентифицирует этот элемент. */
|
2014-12-15 20:43:24 +00:00
|
|
|
String getID() const override { return "Subquery"; }
|
|
|
|
|
|
|
|
ASTPtr clone() const override
|
|
|
|
{
|
2016-05-28 15:42:22 +00:00
|
|
|
const auto res = std::make_shared<ASTSubquery>(*this);
|
2014-12-15 20:43:24 +00:00
|
|
|
ASTPtr ptr{res};
|
2014-12-17 15:26:24 +00:00
|
|
|
|
2014-12-15 20:43:24 +00:00
|
|
|
res->children.clear();
|
|
|
|
|
|
|
|
for (const auto & child : children)
|
|
|
|
res->children.emplace_back(child->clone());
|
2012-08-22 18:46:09 +00:00
|
|
|
|
2014-12-15 20:43:24 +00:00
|
|
|
return ptr;
|
|
|
|
}
|
2012-08-22 23:09:26 +00:00
|
|
|
|
2015-05-03 09:13:08 +00:00
|
|
|
String getColumnName() const override { return getTreeID(); }
|
2015-08-06 03:26:27 +00:00
|
|
|
|
|
|
|
protected:
|
2015-08-06 23:46:15 +00:00
|
|
|
void formatImplWithoutAlias(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
|
2015-08-06 03:26:27 +00:00
|
|
|
{
|
|
|
|
std::string indent_str = settings.one_line ? "" : std::string(4 * frame.indent, ' ');
|
|
|
|
std::string nl_or_nothing = settings.one_line ? "" : "\n";
|
|
|
|
|
|
|
|
settings.ostr << nl_or_nothing << indent_str << "(" << nl_or_nothing;
|
2015-08-09 05:10:43 +00:00
|
|
|
FormatStateStacked frame_nested = frame;
|
|
|
|
frame_nested.need_parens = false;
|
|
|
|
++frame_nested.indent;
|
|
|
|
children[0]->formatImpl(settings, state, frame_nested);
|
2015-08-06 03:26:27 +00:00
|
|
|
settings.ostr << nl_or_nothing << indent_str << ")";
|
|
|
|
}
|
2012-08-22 18:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|