mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
97f2a2213e
* Move some code outside dbms/src folder * Fix paths
47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <Parsers/ASTWithAlias.h>
|
|
#include <Parsers/ASTExpressionList.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
/** AST for function application or operator.
|
|
*/
|
|
class ASTFunction : public ASTWithAlias
|
|
{
|
|
public:
|
|
String name;
|
|
ASTPtr arguments;
|
|
/// parameters - for parametric aggregate function. Example: quantile(0.9)(x) - what in first parens are 'parameters'.
|
|
ASTPtr parameters;
|
|
|
|
public:
|
|
/** Get text identifying the AST node. */
|
|
String getID(char delim) const override;
|
|
|
|
ASTPtr clone() const override;
|
|
|
|
protected:
|
|
void formatImplWithoutAlias(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
|
|
void appendColumnNameImpl(WriteBuffer & ostr) const override;
|
|
};
|
|
|
|
|
|
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)... };
|
|
|
|
return function;
|
|
}
|
|
|
|
}
|