test: Add native expression optimizer for e2e tests#26903
Draft
pdabre12 wants to merge 10 commits into
Draft
Conversation
Contributor
Reviewer's GuideIntroduces a configurable expression optimizer path for native e2e tests by wiring a native expression optimizer factory into the testing stack, allowing tests to exercise either the built-in or native optimizer via a serving reference, while updating native expression function handle generation and relaxing or disabling a few flaky tests. Sequence diagram for test-mode expression optimizer selection in e2e testssequenceDiagram
actor Test
participant TestingPrestoServer
participant ExpressionOptimizerManager
participant ExpressionOptimizerFactory
participant RowExpressionOptimizer as BuiltInOptimizer
participant NativeExpressionOptimizer as NativeOptimizer
Test->>TestingPrestoServer: new TestingPrestoServer(...)
TestingPrestoServer->>ExpressionOptimizerManager: new ExpressionOptimizerManager(...)
activate ExpressionOptimizerManager
ExpressionOptimizerManager->>BuiltInOptimizer: new RowExpressionOptimizer(FunctionAndTypeManager)
ExpressionOptimizerManager->>ExpressionOptimizerManager: put(DEFAULT_EXPRESSION_OPTIMIZER_NAME, BuiltInOptimizer)
ExpressionOptimizerManager->>ExpressionOptimizerManager: servingExpressionOptimizer.set(BuiltInOptimizer)
deactivate ExpressionOptimizerManager
TestingPrestoServer->>ExpressionOptimizerManager: loadExpressionOptimizerFactories()
activate ExpressionOptimizerManager
ExpressionOptimizerManager->>ExpressionOptimizerFactory: createExpressionOptimizer(context)
ExpressionOptimizerFactory-->>ExpressionOptimizerManager: NativeOptimizer
ExpressionOptimizerManager->>ExpressionOptimizerManager: put(nativeName, NativeOptimizer)
ExpressionOptimizerManager->>ExpressionOptimizerManager: servingExpressionOptimizer.compareAndSet(current, NativeOptimizer)
deactivate ExpressionOptimizerManager
TestingPrestoServer->>ExpressionOptimizerManager: enableTestMode()
ExpressionOptimizerManager->>ExpressionOptimizerManager: testMode = true
Test->>ExpressionOptimizerManager: getExpressionOptimizer(connectorSession)
activate ExpressionOptimizerManager
ExpressionOptimizerManager->>ExpressionOptimizerManager: if testMode
ExpressionOptimizerManager-->>Test: servingExpressionOptimizer.get() (NativeOptimizer)
deactivate ExpressionOptimizerManager
Sequence diagram for updated native function handle generationsequenceDiagram
participant VeloxToPrestoExprConverter as Converter
participant CallTypedExpr as VeloxCall
participant Util as PrestoUtil
participant BuiltInFunctionHandle
participant SqlFunctionHandle
Converter->>VeloxCall: getName()
VeloxCall-->>Converter: exprName
Converter->>VeloxCall: inputs()
VeloxCall-->>Converter: exprInputs
Converter->>Converter: build argumentTypes and signature
Converter->>PrestoUtil: getFunctionNameParts(exprName)
PrestoUtil-->>Converter: parts
alt presto default namespace
Converter->>BuiltInFunctionHandle: new BuiltInFunctionHandle()
BuiltInFunctionHandle-->>Converter: builtInFunctionHandle
Converter->>Converter: functionHandle = builtInFunctionHandle
else sql function
Converter->>Converter: functionId = toSqlFunctionId(exprName, signature.argumentTypes)
Converter->>SqlFunctionHandle: new SqlFunctionHandle()
SqlFunctionHandle-->>Converter: sqlFunctionHandle
Converter->>Converter: sqlFunctionHandle.functionId = functionId
Converter->>Converter: functionHandle = sqlFunctionHandle
end
Converter->>Converter: attach functionHandle to CallExpression JSON
Class diagram for updated ExpressionOptimizerManager test-mode behaviorclassDiagram
class ExpressionOptimizerManager {
- PluginNodeManager nodeManager
- FunctionAndTypeManager functionAndTypeManager
- RowExpressionSerde rowExpressionSerde
- FunctionResolution functionResolution
- File configurationDirectory
- Map~String,ExpressionOptimizerFactory~ expressionOptimizerFactories
- Map~String,ExpressionOptimizer~ expressionOptimizers
- AtomicReference~ExpressionOptimizer~ servingExpressionOptimizer
- boolean testMode
+ ExpressionOptimizerManager(PluginNodeManager nodeManager, FunctionAndTypeManager functionAndTypeManager, RowExpressionSerde rowExpressionSerde, File configurationDirectory)
+ void loadExpressionOptimizerFactories()
+ void loadExpressionOptimizerFactory(String factoryName, String optimizerName)
+ void addExpressionOptimizerFactory(ExpressionOptimizerFactory expressionOptimizerFactory)
+ ExpressionOptimizer getExpressionOptimizer(ConnectorSession connectorSession)
+ void enableTestMode()
}
class ExpressionOptimizerFactory {
+ ExpressionOptimizer createExpressionOptimizer(ExpressionOptimizerContext context)
}
class ExpressionOptimizer {
<<interface>>
+ RowExpression optimize(RowExpression expression)
}
class RowExpressionOptimizer {
+ RowExpressionOptimizer(FunctionAndTypeManager functionAndTypeManager)
+ RowExpression optimize(RowExpression expression)
}
class TestingPrestoServer {
- ExpressionOptimizerManager expressionManager
+ TestingPrestoServer(...)
}
ExpressionOptimizerManager o--> ExpressionOptimizerFactory : uses
ExpressionOptimizerManager o--> ExpressionOptimizer : manages
ExpressionOptimizer <|.. RowExpressionOptimizer
TestingPrestoServer --> ExpressionOptimizerManager : configures
class BuiltInFunctionHandle {
+ String _type
+ Signature signature
}
class SqlFunctionHandle {
+ String _type
+ String functionId
+ String version
}
class Signature {
+ String name
+ List~String~ argumentTypes
+ String returnType
+ boolean variableArity
}
class VeloxToPrestoExprConverter {
+ CallExpressionPtr getCallExpression(CallTypedExpr* expr)
}
VeloxToPrestoExprConverter --> BuiltInFunctionHandle : may create
VeloxToPrestoExprConverter --> SqlFunctionHandle : may create
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
5f23456 to
988995d
Compare
pramodsatya
added a commit
that referenced
this pull request
Jan 9, 2026
) ## Description Enables Velox to Presto expression conversion for lambda expressions. ## Motivation and Context Velox to Presto expression conversion currently returns the input `RowExpression` for Velox expressions of types `kConcat`, `kInput`, and `kLambda`. This is incorrect for Lambda expressions because Velox `ExprOptimizer` optimizes the body of `core::LambdaTypedExpr` and the result isn't translated back to Presto. This PR adds the missing wiring for Velox to Presto lambda expression conversion required to complete the constant folding. `getRowExpression` API in `VeloxToPrestoExprConverter` takes an optional `RowExpression` for the default result as and argument. This was being returned for lambda, concat and input Velox expressions. With this change lambda expressions are converted and the Velox ExprOptimizer never returns concat or input expressions. So the default result parameter is unused and can be removed. ## Impact Fixes errors uncovered by `array_sort` in #26903. ## Test Plan Added e2e tests. ``` == NO RELEASE NOTE == ```
7 tasks
tdcmeehan
pushed a commit
to rdtr/presto
that referenced
this pull request
Jan 14, 2026
…stodb#26913) ## Description Enables Velox to Presto expression conversion for lambda expressions. ## Motivation and Context Velox to Presto expression conversion currently returns the input `RowExpression` for Velox expressions of types `kConcat`, `kInput`, and `kLambda`. This is incorrect for Lambda expressions because Velox `ExprOptimizer` optimizes the body of `core::LambdaTypedExpr` and the result isn't translated back to Presto. This PR adds the missing wiring for Velox to Presto lambda expression conversion required to complete the constant folding. `getRowExpression` API in `VeloxToPrestoExprConverter` takes an optional `RowExpression` for the default result as and argument. This was being returned for lambda, concat and input Velox expressions. With this change lambda expressions are converted and the Velox ExprOptimizer never returns concat or input expressions. So the default result parameter is unused and can be removed. ## Impact Fixes errors uncovered by `array_sort` in prestodb#26903. ## Test Plan Added e2e tests. ``` == NO RELEASE NOTE == ```
pdabre12
added a commit
that referenced
this pull request
Jan 22, 2026
## Description Add parsing logic for `NativeFunctionHandle`. All functions under `NativeFunctionNamespaceManager` now return and parse `NativeFunctionHandle` instead of `SqlFunctionHandle`. ## Motivation and Context This change is required for `VeloxToPrestoExpr` when the native expression optimizer is enabled. During translation from a Velox row expression back to a Presto row expression, we must construct a function handle that is supported by `NativeFunctionNamespaceManager` when the underlying function is native. To avoid parsing different function handle types, all functions under `NativeFunctionNamespaceManager` now consistently return and parse `NativeFunctionHandle`. Issues discovered by : #26903 ## Impact There is no direct user-facing impact. This change only affects internal function handle construction and parsing. ## Test Plan CI, Unit tests. ## 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. - [x] If adding new dependencies, verified they have an [OpenSSF Scorecard](https://securityscorecards.dev/#the-checks) score of 5.0 or higher (or obtained explicit TSC approval for lower scores). ## 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 support for `NativeFunctionHandle` parsing. ```
fa865f4 to
37b8aad
Compare
This reverts commit 366a7fa.
0db6a9e to
186914d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Motivation and Context
Impact
Test Plan
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.
If release note is NOT required, use: