Skip to content

opt: don't use outer columns as implicit grouping columns#68678

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
DrewKimball:grouping
Aug 17, 2021
Merged

opt: don't use outer columns as implicit grouping columns#68678
craig[bot] merged 1 commit intocockroachdb:masterfrom
DrewKimball:grouping

Conversation

@DrewKimball
Copy link
Copy Markdown
Collaborator

Previously, the optbuilder logic would add any outer column that is
referenced in a grouping context to the set of grouping columns. This
is correct in some cases, because outer columns are effectively constant,
and can just be removed by norm rules. However, it is incorrect in the
case when there are no grouping columns, e.g. a ScalarGroupBy. In that
case, the ScalarGroupBy would inadvertently be converted into a GroupBy.
This patch modifies the optbuilder to simply ignore outer columns in a
grouping context.

Fixes #68290

Release note: None

Previously, the optbuilder logic would add any outer column that is
referenced in a grouping context to the set of grouping columns. This
is correct in some cases, because outer columns are effectively constant,
and can just be removed by norm rules. However, it is incorrect in the
case when there are no grouping columns, e.g. a `ScalarGroupBy`. In that
case, the `ScalarGroupBy` would inadvertently be converted into a `GroupBy`.
This patch modifies the optbuilder to simply ignore outer columns in a
grouping context.

Fixes cockroachdb#68290

Release note: None
@DrewKimball DrewKimball requested review from a team and RaduBerinde August 11, 2021 00:02
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor

@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.

Nice! :lgtm:

You might want to wait for Radu to take a look though - I'm not super familiar with this part of the code.

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

@DrewKimball
Copy link
Copy Markdown
Collaborator Author

@RaduBerinde mind taking look when you have time?

Copy link
Copy Markdown
Member

@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.

:lgtm: Sorry for the delay, I was out until last night.

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

@DrewKimball
Copy link
Copy Markdown
Collaborator Author

No worries! This is pretty low-priority

@DrewKimball
Copy link
Copy Markdown
Collaborator Author

TFTRs!

@DrewKimball
Copy link
Copy Markdown
Collaborator Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Aug 17, 2021

Build succeeded:

@craig craig bot merged commit b69e790 into cockroachdb:master Aug 17, 2021
@DrewKimball DrewKimball deleted the grouping branch August 17, 2021 17:54
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.

opt: group-by instead of scalar-group-by in subquery

4 participants