#include #include #include #include #include #include #include namespace DB { bool ParserCreateFunctionQuery::parseImpl(IParser::Pos & pos, ASTPtr & node, Expected & expected) { ParserKeyword s_create(Keyword::CREATE); ParserKeyword s_function(Keyword::FUNCTION); ParserKeyword s_or_replace(Keyword::OR_REPLACE); ParserKeyword s_if_not_exists(Keyword::IF_NOT_EXISTS); ParserKeyword s_on(Keyword::ON); ParserIdentifier function_name_p; ParserKeyword s_as(Keyword::AS); ParserExpression 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(); 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; } }