add makeASTFunction factory-function. #[NETR-12739]

This commit is contained in:
Andrey Mironov 2014-09-25 19:00:12 +04:00
parent 142d0a49c0
commit cee035439e

View File

@ -1,6 +1,7 @@
#pragma once
#include <DB/Parsers/ASTWithAlias.h>
#include <DB/Parsers/ASTExpressionList.h>
#include <DB/Functions/IFunction.h>
#include <DB/AggregateFunctions/IAggregateFunction.h>
#include <DB/IO/WriteBufferFromString.h>
@ -81,4 +82,20 @@ public:
}
};
template <typename... Args>
ASTPtr makeASTFunction(const String & name, Args &&... args)
{
const auto function = new ASTFunction{};
ASTPtr result{function};
function->name = name;
function->arguments = new ASTExpressionList{};
function->children.push_back(function->arguments);
function->arguments->children = { std::forward<Args>(args)... };
return result;
}
}