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: improve FDs for Intersect and Except variants #66444

Merged
merged 1 commit into from
Jun 15, 2021

Conversation

RaduBerinde
Copy link
Member

@RaduBerinde RaduBerinde commented Jun 14, 2021

We can pass through FDs from the left side on Except/ExceptAll; and we
can pass through FDs from both sides on Intersect/IntersectAll.

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@@ -551,6 +551,23 @@ func (f *FuncDepSet) CopyFrom(fdset *FuncDepSet) {
f.hasKey = fdset.hasKey
}

// RemapFrom copies the given FD into this FD, remapping column IDs according to
// the given function.
func (f *FuncDepSet) RemapFrom(fdset *FuncDepSet, remap func(opt.ColumnID) opt.ColumnID) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a function TranslateColSet in opt/colset.go that already has this sort of logic - you could just pass in the left and output ColLists here and call TranslateColSet

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.

Nice!

We can pass through FDs from the left side on Intersect/IntersectAll,
and we can pass through FDs from both sides on Except/ExceptAll.

Isn't it the opposite? (i.e., can pass from both sides for intersect but not except?) I think the code is already doing the right thing, just seems like the commit/PR message needs to be updated.

Might be worth adding an explicit test that this is the case, though.

Reviewed 15 of 15 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @DrewKimball)


pkg/sql/opt/props/func_dep.go, line 556 at r1 (raw file):

Previously, DrewKimball (Drew Kimball) wrote…

There's a function TranslateColSet in opt/colset.go that already has this sort of logic - you could just pass in the left and output ColLists here and call TranslateColSet

Agreed. I did something similar here with OrderingChoice:

func (oc *OrderingChoice) RemapColumns(from, to opt.ColList) OrderingChoice {

We can pass through FDs from the left side on Except/ExceptAll; and we
can pass through FDs from both sides on Intersect/IntersectAll.

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.

Commit message fixed. There are some existing tests in logprops/set.

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


pkg/sql/opt/props/func_dep.go, line 556 at r1 (raw file):

Previously, rytaft (Rebecca Taft) wrote…

Agreed. I did something similar here with OrderingChoice:

func (oc *OrderingChoice) RemapColumns(from, to opt.ColList) OrderingChoice {

Done. I found that most current usecases of this function legitimately pass in columns that are not in the from list. I updated the comments and added a Strict version and converted some of the existing calls.

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 8 of 8 files at r2.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @DrewKimball)


pkg/sql/opt/props/func_dep.go, line 556 at r1 (raw file):

Previously, RaduBerinde wrote…

Done. I found that most current usecases of this function legitimately pass in columns that are not in the from list. I updated the comments and added a Strict version and converted some of the existing calls.

Thanks!

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.

TFTRs!

bors r+

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

@craig
Copy link
Contributor

craig bot commented Jun 15, 2021

Build succeeded:

@craig craig bot merged commit a61f01d into cockroachdb:master Jun 15, 2021
@RaduBerinde RaduBerinde deleted the set-fds branch June 15, 2021 16:47
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