ClickHouse/dbms/src/Parsers/ASTFunction.h

47 lines
1.1 KiB
C++
Raw Normal View History

2011-09-19 01:42:16 +00:00
#pragma once
2010-06-24 19:12:10 +00:00
#include <Parsers/ASTWithAlias.h>
#include <Parsers/ASTExpressionList.h>
2010-06-24 19:12:10 +00:00
namespace DB
{
/** AST for function application or operator.
2010-06-24 19:12:10 +00:00
*/
2014-07-03 22:39:13 +00:00
class ASTFunction : public ASTWithAlias
2010-06-24 19:12:10 +00:00
{
public:
String name;
ASTPtr arguments;
/// parameters - for parametric aggregate function. Example: quantile(0.9)(x) - what in first parens are 'parameters'.
ASTPtr parameters;
2016-05-03 23:19:14 +00:00
public:
/** Get text identifying the AST node. */
String getID(char delim) const override;
2011-12-12 06:15:34 +00:00
ASTPtr clone() const override;
protected:
void formatImplWithoutAlias(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
void appendColumnNameImpl(WriteBuffer & ostr) const override;
2010-06-24 19:12:10 +00:00
};
template <typename... Args>
std::shared_ptr<ASTFunction> makeASTFunction(const String & name, Args &&... args)
{
const auto function = std::make_shared<ASTFunction>();
function->name = name;
function->arguments = std::make_shared<ASTExpressionList>();
function->children.push_back(function->arguments);
function->arguments->children = { std::forward<Args>(args)... };
2018-02-26 03:37:08 +00:00
return function;
}
2010-06-24 19:12:10 +00:00
}