#include #include #include #include #include #include #include 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(); node = create_function_query; create_function_query->function_name = function_name->as().name(); create_function_query->function_core = 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; } }