1#pragma once
2
3#include <Parsers/ASTWithAlias.h>
4#include <Parsers/ASTExpressionList.h>
5
6
7namespace DB
8{
9
10/** AST for function application or operator.
11 */
12class ASTFunction : public ASTWithAlias
13{
14public:
15 String name;
16 ASTPtr arguments;
17 /// parameters - for parametric aggregate function. Example: quantile(0.9)(x) - what in first parens are 'parameters'.
18 ASTPtr parameters;
19
20public:
21 /** Get text identifying the AST node. */
22 String getID(char delim) const override;
23
24 ASTPtr clone() const override;
25
26protected:
27 void formatImplWithoutAlias(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
28 void appendColumnNameImpl(WriteBuffer & ostr) const override;
29};
30
31
32template <typename... Args>
33std::shared_ptr<ASTFunction> makeASTFunction(const String & name, Args &&... args)
34{
35 const auto function = std::make_shared<ASTFunction>();
36
37 function->name = name;
38 function->arguments = std::make_shared<ASTExpressionList>();
39 function->children.push_back(function->arguments);
40
41 function->arguments->children = { std::forward<Args>(args)... };
42
43 return function;
44}
45
46}
47