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

Remove cross join if one side of input is single row constant #23081

Merged
merged 1 commit into from
Jul 16, 2024

Conversation

feilong-liu
Copy link
Contributor

@feilong-liu feilong-liu commented Jun 26, 2024

Description

Fix #23074

When one side of cross join inputs is single row with constant values, we can remove this cross join and replace it with a project node. This will simplify the plan, and enable more following optimizations, such as filter pushdown etc.

Motivation and Context

We observed savings enabled by this optimization in our workload.

Impact

We observed savings enabled by this optimization in our workload.

Test Plan

Unit tests

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
* Add an optimization to remove cross join when one side of inputs is single row of constant values. The optimization is controlled by session property `remove_cross_join_with_constant_single_row_input` :pr:`23081`

@feilong-liu feilong-liu requested review from jaystarshot and a team as code owners June 26, 2024 00:35
@feilong-liu feilong-liu marked this pull request as draft June 26, 2024 00:35
@feilong-liu feilong-liu force-pushed the cross_join_single_val branch 4 times, most recently from 0fcb97b to 8e24401 Compare June 26, 2024 16:47
@feilong-liu feilong-liu marked this pull request as ready for review June 26, 2024 17:49
Copy link
Contributor

@kaikalur kaikalur left a comment

Choose a reason for hiding this comment

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

Please add a couple of tests with maps and arrays literals where we see the most impact

Copy link
Contributor

@kaikalur kaikalur left a comment

Choose a reason for hiding this comment

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

Add tests with cross join a constant with filter after the join

@feilong-liu
Copy link
Contributor Author

Please add a couple of tests with maps and arrays literals where we see the most impact

Added these tests

ajaygeorge
ajaygeorge previously approved these changes Jul 15, 2024
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.

Looks good.
Added some nits. Feel free to skip if the suggestions doesn't make sense.

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.

Looks good.

@feilong-liu feilong-liu merged commit 14e4fe5 into prestodb:master Jul 16, 2024
56 checks passed
@feilong-liu feilong-liu deleted the cross_join_single_val branch July 16, 2024 06:39
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.

Inline cosntant cross joins
3 participants