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: fix bug in ExtractJoinEqualities rule #57524

Merged
merged 1 commit into from
Dec 4, 2020

Conversation

RaduBerinde
Copy link
Member

If the join is semi/anti, this rule generates an incorrect projection
(which passes through columns not in input).

Similar to #57501. Other normalization rules prune the columns so this
doesn't lead to a bad outcome (at least in most cases).

I will add an assertion in CheckExpr for this condition in a separate
PR - without this fix, the assertion fires on an existing test.

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@mgartner
Copy link
Collaborator

mgartner commented Dec 4, 2020

without this fix, the assertion fires on an existing test.

You mean "with this fix"?

Copy link
Collaborator

@mgartner mgartner left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -551,9 +551,13 @@ func (c *CustomFuncs) ExtractJoinEquality(
newFilters,
private,
)
outputCols := leftCols
if joinOp != opt.SemiJoinOp && joinOp != opt.AntiJoinOp {
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] maybe explain here that semi and anti joins don't output columns from the right side, unless you think that's obvious enough that an explanation isn't warranted.

If the join is semi/anti, this rule generates an incorrect projection
(which passes through columns not in input).

Similar to cockroachdb#57501. Other normalization rules prune the columns so this
doesn't lead to a bad outcome (at least in most cases).

I will add an assertion in CheckExpr for this condition in a separate
PR - without this fix, the assertion fires on an existing test.

Release note: None
Copy link
Member Author

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

Without this fix (this PR), if I add the assertion to CheckExpr, it panics on an existing test. Which is to say, the condition addressed here will be covered by tests once I make that other change.

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


pkg/sql/opt/norm/join_funcs.go, line 555 at r1 (raw file):

Previously, mgartner (Marcus Gartner) wrote…

[nit] maybe explain here that semi and anti joins don't output columns from the right side, unless you think that's obvious enough that an explanation isn't warranted.

Done.

@RaduBerinde
Copy link
Member Author

bors r+

@craig
Copy link
Contributor

craig bot commented Dec 4, 2020

Build failed:

@RaduBerinde
Copy link
Member Author

bors r+

@craig
Copy link
Contributor

craig bot commented Dec 4, 2020

Build succeeded:

@craig craig bot merged commit aa69b42 into cockroachdb:master Dec 4, 2020
@RaduBerinde RaduBerinde deleted the inline-eq-join-bug branch December 5, 2020 02:34
@rafiss rafiss added this to the 20.2 milestone Apr 22, 2021
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