-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: add rule to reduce IS DISTINCT FROM NULL in join filters #53180
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 3 files at r1.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @DrewKimball)
pkg/sql/opt/norm/testdata/rules/join, line 2157 at r1 (raw file):
└── a.k:1 = a2.f:9 [outer=(1,9), constraints=(/1: (/NULL - ]; /9: (/NULL - ]), fd=(1)==(9), (9)==(1)] # Can't simplify: one equality condition has columns from same side of join.
It sounds like this is a test case we still want. This test happens to fail now because a.f=a.f
is simplified to a IS DISTINCT FROM NULL
, but the comment here claims that the point of the test is to ensure full-join aren't simplified when columns from the same side of the join are referenced in one of the ON filters.
I think you could test this same case by changing a.f=a.f
to a.f=a.i
, and it would remain a full-join even with your normalization rule.
(As an aside, this is a good reminder why comments explaining each test are extremely helpful.)
This PR introduces a normalization rule that removes an `IS NOT NULL` condition on a not-null column from the ON condition of a left or full join. Ex: ``` SELECT * FROM abc FULL JOIN abc AS abc2 ON abc.a IS NOT NULL; => SELECT * FROM abc FULL JOIN abc AS abc2 ON True; ``` Fixes cockroachdb#48173 Release note: None
4148d01
to
26dabe7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @mgartner)
pkg/sql/opt/norm/testdata/rules/join, line 2157 at r1 (raw file):
Previously, mgartner (Marcus Gartner) wrote…
It sounds like this is a test case we still want. This test happens to fail now because
a.f=a.f
is simplified toa IS DISTINCT FROM NULL
, but the comment here claims that the point of the test is to ensure full-join aren't simplified when columns from the same side of the join are referenced in one of the ON filters.I think you could test this same case by changing
a.f=a.f
toa.f=a.i
, and it would remain a full-join even with your normalization rule.(As an aside, this is a good reminder why comments explaining each test are extremely helpful.)
Ah, nice catch. Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 3 files at r1, 1 of 1 files at r2.
Reviewable status: complete! 1 of 0 LGTMs obtained
TFTR! |
bors r+ |
This PR was included in a batch that was canceled, it will be automatically retried |
Build failed (retrying...): |
Build succeeded: |
This PR introduces a normalization rule that removes an
IS NOT NULL
condition on a not-null column from the ON condition of a left or full
join.
Ex:
Fixes #48173
Release note: None