Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
chhtimeplus committed Jul 15, 2024
1 parent e4399b2 commit ae6c4c4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 19 deletions.
19 changes: 4 additions & 15 deletions src/Interpreters/InterpreterCreateFunctionQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ BlockIO InterpreterCreateFunctionQuery::execute()
bool replace_if_exists = create_function_query.or_replace;

/// proton: starts. Handle javascript UDF
if (create_function_query.isJavaScript())
return handleJavaScriptUDF(throw_if_exists, replace_if_exists);
else if (create_function_query.isRemote())
return handleRemoteUDF(throw_if_exists, replace_if_exists);
if (create_function_query.isJavaScript() || create_function_query.isRemote())
return handleUDF(throw_if_exists, replace_if_exists);
/// proton: ends

UserDefinedSQLFunctionFactory::instance().registerFunction(current_context, function_name, query_ptr, throw_if_exists, replace_if_exists);
Expand All @@ -66,10 +64,10 @@ BlockIO InterpreterCreateFunctionQuery::execute()
}

/// proton: starts
BlockIO InterpreterCreateFunctionQuery::handleJavaScriptUDF(bool throw_if_exists, bool replace_if_exists)
BlockIO InterpreterCreateFunctionQuery::handleUDF(bool throw_if_exists, bool replace_if_exists)
{
ASTCreateFunctionQuery & create = query_ptr->as<ASTCreateFunctionQuery &>();
assert(create.isJavaScript());
assert(create.isJavaScript() || create.isRemote());

const auto func_name = create.getFunctionName();
Poco::JSON::Object::Ptr func = create.toJSON();
Expand All @@ -78,14 +76,5 @@ BlockIO InterpreterCreateFunctionQuery::handleJavaScriptUDF(bool throw_if_exists
return {};
}

BlockIO InterpreterCreateFunctionQuery::handleRemoteUDF(bool throw_if_exists, bool replace_if_exists)
{
ASTCreateFunctionQuery & create = query_ptr->as<ASTCreateFunctionQuery &>();
assert(create.isRemote());
const auto func_name = create.getFunctionName();
Poco::JSON::Object::Ptr func = create.toJSON();
UserDefinedFunctionFactory::instance().registerFunction(getContext(), func_name, func, throw_if_exists, replace_if_exists);
return {};
}
/// proton: ends
}
3 changes: 1 addition & 2 deletions src/Interpreters/InterpreterCreateFunctionQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class InterpreterCreateFunctionQuery : public IInterpreter, WithMutableContext
ASTPtr query_ptr;

/// proton: starts
BlockIO handleJavaScriptUDF(bool throw_if_exists, bool replace_if_exists);
BlockIO handleRemoteUDF(bool throw_if_exists, bool replace_if_exists);
BlockIO handleUDF(bool throw_if_exists, bool replace_if_exists);
/// proton: ends
};

Expand Down
2 changes: 2 additions & 0 deletions src/Parsers/ASTCreateFunctionQuery.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <cassert>
#include <IO/Operators.h>
#include <Parsers/ASTCreateFunctionQuery.h>
#include <Parsers/ASTExpressionList.h>
Expand Down Expand Up @@ -155,6 +156,7 @@ Poco::JSON::Object::Ptr ASTCreateFunctionQuery::toJSON() const
/// remote function
if (is_remote)
{
assert(function_core != nullptr);
inner_func->set("url", function_core->as<ASTLiteral>()->value.safeGet<String>());
// auth
if (!function_core->children.empty())
Expand Down
3 changes: 1 addition & 2 deletions src/Parsers/ParserCreateFunctionQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ bool ParserCreateFunctionQuery::parseImpl(IParser::Pos & pos, ASTPtr & node, Exp
if (!lambda_p.parse(pos, function_core, expected))
return false;
}
Poco::JSON::Object::Ptr remote_func_settings = new Poco::JSON::Object();
if (is_remote)
{
if (is_aggregation)
Expand Down Expand Up @@ -164,7 +163,7 @@ bool ParserCreateFunctionQuery::parseImpl(IParser::Pos & pos, ASTPtr & node, Exp
}
else if (method_str != "none")
{
throw Exception("Auth_method must be 'none' or 'auth_header'", ErrorCodes::UNKNOWN_FUNCTION);
throw Exception("AUTH_METHOD must be 'none' or 'auth_header'", ErrorCodes::UNKNOWN_FUNCTION);
}
}
function_core = std::move(url);
Expand Down

0 comments on commit ae6c4c4

Please sign in to comment.