Skip to content

Extend pull lambda out for conditional expression#21344

Merged
feilong-liu merged 1 commit intoprestodb:masterfrom
feilong-liu:fix_pull_lambda
Nov 16, 2023
Merged

Extend pull lambda out for conditional expression#21344
feilong-liu merged 1 commit intoprestodb:masterfrom
feilong-liu:fix_pull_lambda

Conversation

@feilong-liu
Copy link
Contributor

@feilong-liu feilong-liu commented Nov 8, 2023

Description

Try to extract independent expressions from the conditional expressions.

Motivation and Context

In current code, when the expression is in a conditional expression, we will skip them. For example, for transform(col1, x -> if(col3 > 2, col2[2], 0)), we will skip and do not extract anything from the lambda expression. We chose this behavior because expressions in conditional expressions may not be executed.
However, some part of the conditional will always be evaluated, for example in the above expression transform(col1, x -> if(col3 > 2, col2[2], 0)) we can extract col3>2 out, as it's a condition and will always be evaluated. In this PR, I extend the optimizer to extract these expressions.

Impact

Increase the coverage of this optimizer.

Test Plan

Unit test and verifier run test

Contributor checklist

  • Please make sure your submission complies with our development, formatting, commit message, and attribution guidelines.
  • 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.

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== RELEASE NOTES ==

General Changes
* Fix lambda expression pull out optimizer so that it will be able to extract independent expressions from conditional expression.

@feilong-liu feilong-liu requested a review from a team as a code owner November 8, 2023 21:39
@feilong-liu feilong-liu marked this pull request as draft November 8, 2023 21:39
@feilong-liu feilong-liu marked this pull request as ready for review November 10, 2023 00:13
Copy link
Contributor

@ajaygeorge ajaygeorge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stamping since it is already reviewed.

@feilong-liu feilong-liu merged commit 1fa07f4 into prestodb:master Nov 16, 2023
@feilong-liu feilong-liu deleted the fix_pull_lambda branch November 16, 2023 21:48
@wanglinsong wanglinsong mentioned this pull request Feb 12, 2024
64 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants