Skip to content

Commit

Permalink
Fix unit test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe-Abraham committed Feb 7, 2025
1 parent ccc3096 commit 0b99987
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
20 changes: 14 additions & 6 deletions velox/functions/remote/client/tests/RemoteFunctionRestTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,39 +55,47 @@ class RemoteFunctionRestTest
void registerRemoteFunctions() const {
RemoteVectorFunctionMetadata metadata;
metadata.serdeFormat = remote::PageFormat::PRESTO_PAGE;
metadata.location = location_;

auto functionName = "remote_abs";
metadata.location = location_ + '/' + functionName;
auto absSignature = {exec::FunctionSignatureBuilder()
.returnType("integer")
.argumentType("integer")
.build()};
registerRemoteFunction("remote_abs", absSignature, metadata);
registerRemoteFunction(functionName, absSignature, metadata);

functionName = "remote_plus";
metadata.location = location_ + '/' + functionName;
auto plusSignatures = {exec::FunctionSignatureBuilder()
.returnType("bigint")
.argumentType("bigint")
.argumentType("bigint")
.build()};
registerRemoteFunction("remote_plus", plusSignatures, metadata);

functionName = "remote_wrong_port";
RemoteVectorFunctionMetadata wrongMetadata = metadata;
wrongMetadata.serdeFormat = remote::PageFormat::PRESTO_PAGE;
wrongMetadata.location = wrongLocation_;
registerRemoteFunction("remote_wrong_port", plusSignatures, wrongMetadata);
wrongMetadata.location = wrongLocation_ + functionName;
registerRemoteFunction(functionName, plusSignatures, wrongMetadata);

functionName = "remote_divide";
metadata.location = location_ + '/' + functionName;
auto divSignatures = {exec::FunctionSignatureBuilder()
.returnType("double")
.argumentType("double")
.argumentType("double")
.build()};
registerRemoteFunction("remote_divide", divSignatures, metadata);
registerRemoteFunction(functionName, divSignatures, metadata);

functionName = "remote_substr";
metadata.location = location_ + '/' + functionName;
auto substrSignatures = {exec::FunctionSignatureBuilder()
.returnType("varchar")
.argumentType("varchar")
.argumentType("integer")
.build()};
registerRemoteFunction("remote_substr", substrSignatures, metadata);
registerRemoteFunction(functionName, substrSignatures, metadata);

// Registers the actual function under a different prefix. This is only
// needed for tests since the HTTP service runs in the same process.
Expand Down
5 changes: 2 additions & 3 deletions velox/functions/remote/server/RemoteFunctionRestService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,8 @@ void session::handle_request(
folly::split('/', path, pathComponents);

std::string functionName;
if (pathComponents.size() >= 7 && pathComponents[1] == "v1" &&
pathComponents[2] == "functions") {
functionName = pathComponents[4];
if (pathComponents.size() <= 2) {
functionName = pathComponents[1];
} else {
res_.result(boost::beast::http::status::bad_request);
res_.set(boost::beast::http::field::content_type, "text/plain");
Expand Down

0 comments on commit 0b99987

Please sign in to comment.