feat(native): Add endpoint for expression optimization in sidecar#26475
feat(native): Add endpoint for expression optimization in sidecar#26475aditi-pandit merged 6 commits intoprestodb:masterfrom
Conversation
There was a problem hiding this comment.
Sorry @pramodsatya, your pull request is larger than the review limit of 150000 diff characters
d3f5a74 to
4224f36
Compare
There was a problem hiding this comment.
Sorry @pramodsatya, your pull request is larger than the review limit of 150000 diff characters
|
@aditi-pandit, @tdcmeehan, could you please take a look? |
presto-native-execution/presto_cpp/main/types/VeloxToPrestoExpr.cpp
Outdated
Show resolved
Hide resolved
presto-native-execution/presto_cpp/main/types/VeloxToPrestoExpr.h
Outdated
Show resolved
Hide resolved
presto-native-execution/presto_cpp/main/types/VeloxToPrestoExpr.cpp
Outdated
Show resolved
Hide resolved
presto-native-execution/presto_cpp/main/types/VeloxToPrestoExpr.cpp
Outdated
Show resolved
Hide resolved
presto-native-execution/presto_cpp/main/types/VeloxToPrestoExpr.cpp
Outdated
Show resolved
Hide resolved
8034891 to
69c7c37
Compare
aditi-pandit
left a comment
There was a problem hiding this comment.
Thanks @pramodsatya. Have bunch of comments.
presto-native-execution/presto_cpp/main/types/tests/VeloxToPrestoExprTest.cpp
Outdated
Show resolved
Hide resolved
69c7c37 to
388eb89
Compare
|
Thanks @aditi-pandit, made the changes as suggested. Could you PTAL? |
388eb89 to
dfb9a2b
Compare
presto-native-execution/presto_cpp/main/types/ExpressionOptimizer.cpp
Outdated
Show resolved
Hide resolved
02fa18e to
b809033
Compare
|
Thanks @aditi-pandit, addressed the comments, could you please take another look? |
aditi-pandit
left a comment
There was a problem hiding this comment.
Thanks @pramodsatya. Code looks good to me.
@czentgr : Do you want to give it a read as well ? If it looks good, then we can get Tim to approve on the Java part as well.
steveburnett
left a comment
There was a problem hiding this comment.
LGTM! (docs)
Pull branch, local doc build. Thanks!
aditi-pandit
left a comment
There was a problem hiding this comment.
Thanks @pramodsatya
Co-authored-by: Pramod Satya <pramod.satya@ibm.com>
d4c428f
aditi-pandit
left a comment
There was a problem hiding this comment.
Thanks @pramodsatya for all the iterations.
) ## Description Add a `ExpressionOptimizer` which delegates to the native sidecar process to evaluate expressions with Velox. ## Motivation and Context #26475 added support for an endpoint in the sidecar for constant folding expressions. This follows up on that by adding an expression interpreter to call that endpoint. For more context: [RFC-0006](https://github.com/prestodb/rfcs/blob/main/RFC-0006-expression-eval.md). ## Impact No impact by default as the old in-memory evaluation is the default. ## Test Plan Tests have been added. ## Contributor checklist - [x] Please make sure your submission complies with our [contributing guide](https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md), in particular [code style](https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md#code-style) and [commit standards](https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md#commit-standards). - [x] PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced. - [x] Documented new properties (with its default value), SQL syntax, functions, or other functionality. - [x] If release notes are required, they follow the [release notes guidelines](https://github.com/prestodb/presto/wiki/Release-Notes-Guidelines). - [x] Adequate tests were added if applicable. - [x] CI passed. ## Release Notes Please follow [release notes guidelines](https://github.com/prestodb/presto/wiki/Release-Notes-Guidelines) and fill in the release notes below. ``` == RELEASE NOTES == Prestissimo (Native Execution) Changes * Add a native expression optimizer for optimizing expressions in the sidecar. ``` --------- Co-authored-by: Timothy Meehan <tdm@fb.com>
Description
To support constant folding and consistent semantics between the Presto Java coordinator and the Presto C++ worker, it is necessary to use consistent expression evaluation. To support this, a native expression evaluation endpoint,
v1/expressions, has been added to the Presto C++ sidecar. This endpoint leverages theExprOptimizerin Velox to optimize Presto expressions.The optimized Velox
core::TypedExprreturned by Velox'sExprOptimizeris converted to a Prestoprotocol::RowExpressionin the Presto native sidecar with helper classVeloxToPrestoExprConverter. The end to end flow between the coordinator and sidecar is as follows:When
OptimizerLevelisEVALUATEDand an error is encountered during expression evaluation, it is converted toNativeSidecarFailureInfowith presto protocol. The list of optimizedRowExpressions andNativeSidecarFailureInfos is returned along with their corresponding indices in the input expressions list. With the fuzzer testing (see test plan), we expect this endpoint to be ready for production workloads.Motivation and Context
The
native-sidecar-pluginwill implement theExpressionOptimizerinterface from Presto SPI to utilize thev1/expressionsendpoint on the sidecar for optimizing Presto expressions using the native expression evaluation engine.The primary goal is to achieve consistency between C++ and Java semantics for expression optimization. With this change, C++ functions including UDFs can be used for constant folding of expressions in the Presto planner.
Please refer to RFC-0006.
Test Plan
Tests have been added by abstracting testcases from
TestRowExpressionInterpreterto an interfaceAbstractTestExpressionInterpreter. This test interface is implemented inTestNativeExpressionInterpreterto test thev1/expressionsendpoint on the sidecar end to end.This feature is still in Beta, and to support production workloads with complete certainty, the Velox expression fuzzer will be extended to test this endpoint with fuzzer generated expressions in a follow-up PR. This should surface any remaining bugs, such as in
VeloxToPrestoExpr.Note: The Velox
ExprOptimizerand logical rewrites are already tested with fuzzer.Release Notes