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

release-20.1: sql: fix execution of non-scalar count(*) #46891

Merged

Conversation

RaduBerinde
Copy link
Member

Backport 1/1 commits from #46879.

/cc @cockroachdb/release


It is possible to have non-scalar aggregations with no grouping columns - this
happens when the grouping columns are constant and reduced by the optimizer. In
this case, we must not produce a row if the input is empty. We plumbed a scalar
flag and type through execution, but there is a special fast path for count(*)
which still relies on just checking if there are no grouping columns.

This change fixes this issue and moves this logic into a helper so that the code
is not duplicated between the row and col exec.

Fixes #45453.

Release note (bug fix): fixed incorrect result with count(*) when grouping on
constant columns.

It is possible to have non-scalar aggregations with no grouping columns - this
happens when the grouping columns are constant and reduced by the optimizer. In
this case, we must not produce a row if the input is empty. We plumbed a scalar
flag and type through execution, but there is a special fast path for `count(*)`
which still relies on just checking if there are no grouping columns.

This change fixes this issue and moves this logic into a helper so that the code
is not duplicated between the row and col exec.

Fixes cockroachdb#45453.

Release note (bug fix): fixed incorrect result with count(*) when grouping on
constant columns.
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 4 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

@RaduBerinde RaduBerinde merged commit 9bd5979 into cockroachdb:release-20.1 Apr 2, 2020
@RaduBerinde RaduBerinde deleted the backport20.1-46879 branch April 2, 2020 15:08
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.

None yet

3 participants