Skip to content

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

Merged
feilong-liu merged 1 commit intoprestodb:masterfrom
feilong-liu:cross_join_single_val
Jul 16, 2024
Merged

Remove cross join if one side of input is single row constant#23081
feilong-liu merged 1 commit intoprestodb:masterfrom
feilong-liu:cross_join_single_val

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 a team and jaystarshot as code owners June 26, 2024 00:35
@feilong-liu feilong-liu requested a review from presto-oss 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 from b80af5a to 05be389 Compare June 26, 2024 00:45
@feilong-liu feilong-liu requested a review from kaikalur June 26, 2024 00:45
@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
@feilong-liu feilong-liu requested a review from rschlussel 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 feilong-liu force-pushed the cross_join_single_val branch from 8e24401 to 8d193e7 Compare June 29, 2024 21:10
@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

@feilong-liu feilong-liu force-pushed the cross_join_single_val branch from 8d193e7 to 519a6cf Compare July 9, 2024 18:06
@feilong-liu feilong-liu requested a review from kaikalur July 9, 2024 18:07
kaikalur
kaikalur previously approved these changes Jul 9, 2024
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.

@feilong-liu feilong-liu force-pushed the cross_join_single_val branch from d6f7af2 to cf57bb0 Compare July 15, 2024 22:08
@feilong-liu feilong-liu requested a review from ajaygeorge July 15, 2024 22:09
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
@feilong-liu feilong-liu deleted the cross_join_single_val branch July 16, 2024 06:39
@tdcmeehan tdcmeehan mentioned this pull request Aug 23, 2024
34 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.

Inline cosntant cross joins

3 participants