mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-13 18:02:24 +00:00
76 lines
2.0 KiB
C++
76 lines
2.0 KiB
C++
#include <Parsers/ParserCreateFunctionQuery.h>
|
|
|
|
#include <Parsers/ASTCreateFunctionQuery.h>
|
|
#include <Parsers/ASTExpressionList.h>
|
|
#include <Parsers/ASTIdentifier.h>
|
|
#include <Parsers/CommonParsers.h>
|
|
#include <Parsers/ExpressionElementParsers.h>
|
|
#include <Parsers/ExpressionListParsers.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
bool ParserCreateFunctionQuery::parseImpl(IParser::Pos & pos, ASTPtr & node, Expected & expected)
|
|
{
|
|
ParserKeyword s_create("CREATE");
|
|
ParserKeyword s_function("FUNCTION");
|
|
ParserKeyword s_or_replace("OR REPLACE");
|
|
ParserKeyword s_if_not_exists("IF NOT EXISTS");
|
|
ParserKeyword s_on("ON");
|
|
ParserIdentifier function_name_p;
|
|
ParserKeyword s_as("AS");
|
|
ParserLambdaExpression lambda_p;
|
|
|
|
ASTPtr function_name;
|
|
ASTPtr function_core;
|
|
|
|
String cluster_str;
|
|
bool or_replace = false;
|
|
bool if_not_exists = false;
|
|
|
|
if (!s_create.ignore(pos, expected))
|
|
return false;
|
|
|
|
if (s_or_replace.ignore(pos, expected))
|
|
or_replace = true;
|
|
|
|
if (!s_function.ignore(pos, expected))
|
|
return false;
|
|
|
|
if (!or_replace && s_if_not_exists.ignore(pos, expected))
|
|
if_not_exists = true;
|
|
|
|
if (!function_name_p.parse(pos, function_name, expected))
|
|
return false;
|
|
|
|
if (s_on.ignore(pos, expected))
|
|
{
|
|
if (!ASTQueryWithOnCluster::parse(pos, cluster_str, expected))
|
|
return false;
|
|
}
|
|
|
|
if (!s_as.ignore(pos, expected))
|
|
return false;
|
|
|
|
if (!lambda_p.parse(pos, function_core, expected))
|
|
return false;
|
|
|
|
auto create_function_query = std::make_shared<ASTCreateFunctionQuery>();
|
|
node = create_function_query;
|
|
|
|
create_function_query->function_name = function_name;
|
|
create_function_query->children.push_back(function_name);
|
|
|
|
create_function_query->function_core = function_core;
|
|
create_function_query->children.push_back(function_core);
|
|
|
|
create_function_query->or_replace = or_replace;
|
|
create_function_query->if_not_exists = if_not_exists;
|
|
create_function_query->cluster = std::move(cluster_str);
|
|
|
|
return true;
|
|
}
|
|
|
|
}
|