Fix array_sort lambda function failure and add e2e lambda function tests #24655
+35
−9
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
Catches an exception while identifying applicable functions and if its a
INVALID_PARAMETER_USAGE
, does not throw.Motivation and Context
When the sidecar is enabled, function signatures are retrieved from the native execution engine. These signatures may differ from those supported by Presto Java. One such example is the
array_sort
function, which supports multiple lambda function signatures:•
array_sort(array(T))
•
array_sort(array(T), function(T, U))
•
array_sort(array(T), function(T, T, bigint))
We should be able to support all these function signatures.
For example:
SELECT array_sort(quantities, (x, y) -> if (x < y, 1, if (x > y, -1, 0))) FROM orders_ex
would throw
Expected a lambda that takes 1 argument\\(s\\) but got 2
SELECT array_sort(quantities, x -> abs(x)) FROM orders_ex
would throw
Expected a lambda that takes 2 argument\\(s\\) but got 1
Under the hood, the coordinator correctly determines the applicable lambda function signature, but during function identification, it also attempts to resolve the other, incompatible signature, resulting in an error.
Impact
No impact.
Test Plan
E2e tests included
Contributor checklist
If release note is NOT required, use: