2011-08-28 08:50:27 +00:00
|
|
|
#pragma once
|
2010-06-24 19:12:10 +00:00
|
|
|
|
|
|
|
#include <DB/Parsers/IAST.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2016-07-17 20:10:50 +00:00
|
|
|
/** List of expressions, for example "a, b + c, f(d)"
|
2010-06-24 19:12:10 +00:00
|
|
|
*/
|
|
|
|
class ASTExpressionList : public IAST
|
|
|
|
{
|
|
|
|
public:
|
2014-12-15 20:43:24 +00:00
|
|
|
ASTExpressionList() = default;
|
2014-12-17 15:26:24 +00:00
|
|
|
ASTExpressionList(const StringRange range_) : IAST(range_) {}
|
2016-05-28 14:14:18 +00:00
|
|
|
|
2014-12-15 20:43:24 +00:00
|
|
|
String getID() const override { return "ExpressionList"; }
|
2011-12-12 06:15:34 +00:00
|
|
|
|
2014-12-15 20:43:24 +00:00
|
|
|
ASTPtr clone() const override
|
2011-12-12 06:15:34 +00:00
|
|
|
{
|
2016-05-28 15:42:22 +00:00
|
|
|
const auto res = std::make_shared<ASTExpressionList>(*this);
|
2011-12-12 06:15:34 +00:00
|
|
|
res->children.clear();
|
2016-05-28 14:14:18 +00:00
|
|
|
|
2014-12-15 20:43:24 +00:00
|
|
|
for (const auto & child : children)
|
|
|
|
res->children.emplace_back(child->clone());
|
2011-12-12 06:15:34 +00:00
|
|
|
|
2016-07-17 20:10:50 +00:00
|
|
|
return res;
|
2011-12-12 06:15:34 +00:00
|
|
|
}
|
2015-08-05 21:38:31 +00:00
|
|
|
|
|
|
|
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
|
|
|
|
{
|
|
|
|
for (ASTs::const_iterator it = children.begin(); it != children.end(); ++it)
|
|
|
|
{
|
|
|
|
if (it != children.begin())
|
|
|
|
settings.ostr << ", ";
|
|
|
|
|
|
|
|
(*it)->formatImpl(settings, state, frame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Вывести список выражений в секциях запроса SELECT - по одному выражению на строку.
|
|
|
|
*/
|
|
|
|
void formatImplMultiline(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
|
|
|
|
{
|
|
|
|
std::string indent_str = "\n" + std::string(4 * (frame.indent + 1), ' ');
|
|
|
|
|
|
|
|
++frame.indent;
|
|
|
|
for (ASTs::const_iterator it = children.begin(); it != children.end(); ++it)
|
|
|
|
{
|
|
|
|
if (it != children.begin())
|
|
|
|
settings.ostr << ", ";
|
|
|
|
|
|
|
|
if (children.size() > 1)
|
|
|
|
settings.ostr << indent_str;
|
|
|
|
|
|
|
|
(*it)->formatImpl(settings, state, frame);
|
|
|
|
}
|
|
|
|
}
|
2010-06-24 19:12:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|