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/optbuilder: Fix bug with ORDER BY and aggregate alias #25455

Merged
merged 1 commit into from
May 13, 2018

Conversation

rytaft
Copy link
Collaborator

@rytaft rytaft commented May 13, 2018

This commit fixes a bug in which ordering by an alias of
an aggregate causes an error.

Queries such as:
SELECT SUM(a) AS a2 FROM abcd GROUP BY c ORDER BY a2

were incorrectly causing the error:
error: column "a2" must appear in the GROUP BY clause or be used in an aggregate function

This commit fixes that issue, so now the query builds successfully.

Release note: None

This commit fixes a bug in which ordering by an alias of
an aggregate causes an error.

Queries such as:
`SELECT SUM(a) AS a2 FROM abcd GROUP BY c ORDER BY a2`

were incorrectly causing the error:
`error: column "a2" must appear in the GROUP BY clause or be
used in an aggregate function`

This commit fixes that issue, so now the query builds successfully.

Release note: None
@rytaft rytaft requested a review from a team as a code owner May 13, 2018 17:21
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@RaduBerinde
Copy link
Member

:lgtm:


Review status: 0 of 2 files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@rytaft
Copy link
Collaborator Author

rytaft commented May 13, 2018

Wow that was fast! TFTR :)


Review status: 0 of 2 files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@rytaft
Copy link
Collaborator Author

rytaft commented May 13, 2018

bors r+


Review status: 0 of 2 files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

craig bot pushed a commit that referenced this pull request May 13, 2018
25455: opt/optbuilder: Fix bug with ORDER BY and aggregate alias r=rytaft a=rytaft

This commit fixes a bug in which ordering by an alias of
an aggregate causes an error.

Queries such as:
`SELECT SUM(a) AS a2 FROM abcd GROUP BY c ORDER BY a2`

were incorrectly causing the error:
`error: column "a2" must appear in the GROUP BY clause or be
used in an aggregate function`

This commit fixes that issue, so now the query builds successfully.

Release note: None

Co-authored-by: Rebecca Taft <[email protected]>
@craig
Copy link
Contributor

craig bot commented May 13, 2018

Build succeeded

@craig craig bot merged commit 75d6ea5 into cockroachdb:master May 13, 2018
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.

3 participants