ClickHouse/src/Parsers/ASTCreateFunctionQuery.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
1.5 KiB
C++
Raw Normal View History

#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
{
2022-01-20 08:23:52 +00:00
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 : "");
2022-01-20 08:23:52 +00:00
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);
}
2022-01-20 08:23:52 +00:00
String ASTCreateFunctionQuery::getFunctionName() const
{
String name;
tryGetIdentifierNameInto(function_name, name);
return name;
}
}