mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-02 04:22:03 +00:00
54 lines
1.5 KiB
C++
54 lines
1.5 KiB
C++
#include <Common/quoteString.h>
|
|
#include <IO/Operators.h>
|
|
#include <Parsers/ASTCreateFunctionQuery.h>
|
|
#include <Parsers/ASTExpressionList.h>
|
|
#include <Parsers/ASTFunction.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
ASTPtr ASTCreateFunctionQuery::clone() const
|
|
{
|
|
auto res = std::make_shared<ASTCreateFunctionQuery>(*this);
|
|
res->children.clear();
|
|
|
|
res->function_name = function_name->clone();
|
|
res->children.push_back(res->function_name);
|
|
|
|
res->function_core = function_core->clone();
|
|
res->children.push_back(res->function_core);
|
|
return res;
|
|
}
|
|
|
|
void ASTCreateFunctionQuery::formatImpl(const IAST::FormatSettings & settings, IAST::FormatState & state, IAST::FormatStateStacked frame) const
|
|
{
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << "CREATE ";
|
|
|
|
if (or_replace)
|
|
settings.ostr << "OR REPLACE ";
|
|
|
|
settings.ostr << "FUNCTION ";
|
|
|
|
if (if_not_exists)
|
|
settings.ostr << "IF NOT EXISTS ";
|
|
|
|
settings.ostr << (settings.hilite ? hilite_none : "");
|
|
|
|
settings.ostr << (settings.hilite ? hilite_identifier : "") << backQuoteIfNeed(getFunctionName()) << (settings.hilite ? hilite_none : "");
|
|
|
|
formatOnCluster(settings);
|
|
|
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << " AS " << (settings.hilite ? hilite_none : "");
|
|
function_core->formatImpl(settings, state, frame);
|
|
}
|
|
|
|
String ASTCreateFunctionQuery::getFunctionName() const
|
|
{
|
|
String name;
|
|
tryGetIdentifierNameInto(function_name, name);
|
|
return name;
|
|
}
|
|
|
|
}
|