Skip to content
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

Fix array_sort lambda function failure and add e2e lambda function tests #24655

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pdabre12
Copy link
Contributor

@pdabre12 pdabre12 commented Feb 28, 2025

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

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

If release note is NOT required, use:

== NO RELEASE NOTE ==

@prestodb-ci prestodb-ci added the from:IBM PR from IBM label Feb 28, 2025
@pdabre12 pdabre12 force-pushed the fix-lambda-expressions branch from 116092b to 72c19bd Compare March 3, 2025 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
from:IBM PR from IBM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants