ClickHouse/dbms/include/DB/Parsers/ASTSubquery.h

54 lines
1.3 KiB
C
Raw Normal View History

2012-08-22 18:46:09 +00:00
#pragma once
#include <DB/DataTypes/IDataType.h>
#include <DB/Parsers/ASTWithAlias.h>
2012-08-22 18:46:09 +00:00
namespace DB
{
/** Подзарос SELECT
2012-08-22 18:46:09 +00:00
*/
class ASTSubquery : public ASTWithAlias
2012-08-22 18:46:09 +00:00
{
public:
ASTSubquery() = default;
ASTSubquery(const StringRange range_) : ASTWithAlias(range_) {}
2012-08-22 18:46:09 +00:00
/** Получить текст, который идентифицирует этот элемент. */
String getID() const override { return "Subquery"; }
ASTPtr clone() const override
{
const auto res = new ASTSubquery{*this};
ASTPtr ptr{res};
2014-12-17 15:26: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
return ptr;
}
2012-08-22 23:09:26 +00:00
String getColumnName() const override { return getTreeID(); }
protected:
void formatImplWithoutAlias(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
{
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);
settings.ostr << nl_or_nothing << indent_str << ")";
}
2012-08-22 18:46:09 +00:00
};
}