-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[native] Add support for REST based remote function #23568
base: master
Are you sure you want to change the base?
Conversation
808f416
to
1c7ea23
Compare
86c1f8b
to
3345b51
Compare
0d73f09
to
f530b51
Compare
32a8715
to
5726f00
Compare
a8afff9
to
26f9fe6
Compare
@aditi-pandit Can you please review the changes |
ef746fc
to
098b074
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Joe-Abraham, could you add e2e tests as well?
@@ -18,12 +18,20 @@ add_library( | |||
presto_types OBJECT | |||
PrestoToVeloxQueryPlan.cpp PrestoToVeloxExpr.cpp VeloxPlanValidator.cpp | |||
PrestoToVeloxSplit.cpp PrestoToVeloxConnector.cpp) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: revert newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted the line
@@ -412,6 +421,18 @@ std::optional<TypedExprPtr> VeloxExprConverter::tryConvertLike( | |||
returnType, args, getFunctionName(signature)); | |||
} | |||
|
|||
#ifdef PRESTO_ENABLE_REMOTE_FUNCTIONS | |||
PageFormat fromSerdeString(const std::string_view& serdeName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this as a separate function? There is only one caller and this check can be moved to the caller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved it to the function
@@ -412,6 +421,18 @@ std::optional<TypedExprPtr> VeloxExprConverter::tryConvertLike( | |||
returnType, args, getFunctionName(signature)); | |||
} | |||
|
|||
#ifdef PRESTO_ENABLE_REMOTE_FUNCTIONS | |||
PageFormat fromSerdeString(const std::string_view& serdeName) { | |||
if (serdeName == "presto_page") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid magic literal and use constant variable for "presto_page"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation is done similar to the below code.
if (serdeName == "presto_page") { |
return std::make_shared<CallTypedExpr>( | ||
returnType, args, getFunctionName(sqlFunctionHandle->functionId)); | ||
} | ||
#ifdef PRESTO_ENABLE_REMOTE_FUNCTIONS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this logic to a separate function, say registerVeloxRemoteFunction
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback, I have made the improvements
}; | ||
class ParseError : public Exception { | ||
public: | ||
explicit ParseError(const std::string& message) : Exception(message){}; | ||
explicit ParseError(const std::string& message) : Exception(message) {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Revert these changes. I believe these format-fixes were automatically added on Macos? They would likely cause a failure in format-check CI which runs on linux.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are auto-generated, I have reverted these changes.
@@ -175,7 +175,7 @@ AbstractClasses: | |||
subclasses: | |||
- { name: BuiltInFunctionHandle, key: $static } | |||
- { name: SqlFunctionHandle, key: json_file } | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: revert this newline removal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted back the changes, Is there a need of two empty line?
@@ -74,6 +74,16 @@ target_link_libraries( | |||
${GFLAGS_LIBRARIES} | |||
pthread) | |||
|
|||
if(PRESTO_ENABLE_REMOTE_FUNCTIONS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change needed? No tests have been added for remote functions so could this be reverted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added these as part of build failure in MacOS, removed it.
6af6ddb
to
9929892
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Joe-Abraham,
Is it possible to add these test cases(#23777) as part of this PR?
velox::exec::FunctionSignatureBuilder signatureBuilder; | ||
|
||
for (const auto& typeVar : prestoSignature.typeVariableConstraints) { | ||
signatureBuilder.typeVariable(typeVar.name); | ||
} | ||
|
||
for (const auto& longVar : prestoSignature.longVariableConstraints) { | ||
signatureBuilder.integerVariable(longVar.name); | ||
} | ||
|
||
signatureBuilder.returnType(prestoSignature.returnType); | ||
|
||
for (const auto& argType : prestoSignature.argumentTypes) { | ||
signatureBuilder.argumentType(argType); | ||
} | ||
|
||
if (prestoSignature.variableArity) { | ||
signatureBuilder.variableArity(); | ||
} | ||
|
||
auto signature = signatureBuilder.build(); | ||
std::vector<velox::exec::FunctionSignaturePtr> veloxSignatures = {signature}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe extract this into a separate function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Joe-Abraham.
@@ -342,6 +342,10 @@ std::string SystemConfig::remoteFunctionServerSerde() const { | |||
return optionalProperty(kRemoteFunctionServerSerde).value(); | |||
} | |||
|
|||
std::string SystemConfig::remoteFunctionRestUrl() const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: rename to remoteFunctionServerRestURL()
for consistency
@@ -21,8 +21,16 @@ add_library( | |||
add_dependencies(presto_types presto_operators presto_type_converter velox_type | |||
velox_type_fbhive) | |||
|
|||
target_link_libraries(presto_types presto_type_converter velox_type_fbhive | |||
velox_hive_partition_function velox_tpch_gen velox_functions_json) | |||
target_link_libraries( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: please revert this formatting change.
@@ -127,6 +135,61 @@ std::string getFunctionName(const protocol::SqlFunctionId& functionId) { | |||
|
|||
} // namespace | |||
|
|||
#ifdef PRESTO_ENABLE_REMOTE_FUNCTIONS | |||
TypedExprPtr VeloxExprConverter::registerRestRemoteFunction( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a member function or can it be moved to an anonymous namespace?
@@ -504,10 +567,22 @@ TypedExprPtr VeloxExprConverter::toVeloxExpr( | |||
pexpr.functionHandle)) { | |||
auto args = toVeloxExpr(pexpr.arguments); | |||
auto returnType = typeParser_->parse(pexpr.returnType); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: revert newline.
f11e126
to
7fcb6b0
Compare
Co-authored-by: Wills Feng <wills.feng@ibm.com>
Thank you for the feedback @pdabre12 @pramodsatya, I have added basic test cases to this PR and e2e test case in #23777 |
@Joe-Abraham Please take a look at the failing CI. |
Description
Dependency