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

opt: prevent null-rejection cycle with RightJoin #92102

Merged
merged 1 commit into from
Nov 29, 2022

Conversation

DrewKimball
Copy link
Collaborator

The null-rejection rules that simplify outer joins ignore RightJoin expressions because the CommuteRightJoin rule normally converts RightJoins to LeftJoins. However, in the case when CommuteRightJoin is disabled, we can hit a case where an IS NOT NULL filter gets pushed down but then gets pulled back up by decorrelation rules when it can't simplify the RightJoin, causing a cycle. This patch fixes the problem by preventing RightJoins from requesting null-rejection when CommuteRightJoin is disabled.

Fixes #91917

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @DrewKimball)


-- commits line 11 at r1:
nit: CommuteRightJoin -> CommuteLeftJoin (throughout this paragraph)

The null-rejection rules that simplify outer joins ignore RightJoin
expressions because the `CommuteRightJoin` rule normally converts
RightJoins to LeftJoins. However, in the case when `CommuteRightJoin`
is disabled, we can hit a case where an `IS NOT NULL` filter gets
pushed down but then gets pulled back up by decorrelation rules when
it can't simplify the RightJoin, causing a cycle. This patch fixes
the problem by preventing RightJoins from requesting null-rejection
when `CommuteRightJoin` is disabled.

Fixes cockroachdb#91917

Release note: None
Copy link
Collaborator Author

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @rytaft)


-- commits line 11 at r1:

Previously, rytaft (Rebecca Taft) wrote…

nit: CommuteRightJoin -> CommuteLeftJoin (throughout this paragraph)

Oops, that's a good catch. CommuteRightJoin is actually right, but I need to change it below. Done.

@DrewKimball
Copy link
Collaborator Author

TFTR!
bors r+

@craig
Copy link
Contributor

craig bot commented Nov 28, 2022

Build failed:

@DrewKimball
Copy link
Collaborator Author

bors r+

@craig
Copy link
Contributor

craig bot commented Nov 29, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Nov 29, 2022

Build succeeded:

@craig craig bot merged commit 486b991 into cockroachdb:master Nov 29, 2022
@blathers-crl
Copy link

blathers-crl bot commented Nov 29, 2022

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from d9155e1 to blathers/backport-release-22.1-92102: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.1.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@mgartner
Copy link
Collaborator

Nice find! Thanks for fixing this.

@DrewKimball DrewKimball deleted the cycle branch November 29, 2022 21:12
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.

roachtest: unoptimized-query-oracle/disable-rules=half/rand-tables failed
4 participants