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.2: opt: disallow aggregate/window functions in ORDER BY for UNION #57521

Merged

Conversation

RaduBerinde
Copy link
Member

Backport 1/1 commits from #57498.

/cc @cockroachdb/release


We support aggregates in ORDER BY, but only in the context of a
SELECT. If we have an ORDER BY clause outside a UNION or VALUES, this
results in an internal error (caused by a Project that tries to pass
through columns not in input).

This change presents a proper error for this case. Note that pg also
errors out in these cases.

Note: I am adding a CheckExpr assertion for Project in a separate PR
(it found more issues).

Fixes #57441.

Release note (bug fix): fixed an internal error when using aggregates
and window functions in an ORDER BY for a UNION or VALUES clause.

We support aggregates in ORDER BY, but only in the context of a
SELECT. If we have an ORDER BY clause outside a UNION or VALUES, this
results in an internal error (caused by a Project that tries to pass
through columns not in input).

This change presents a proper error for this case. Note that pg also
errors out in these cases.

Note: I am adding a CheckExpr assertion for Project in a separate PR
(it found more issues).

Fixes cockroachdb#57441.

Release note (bug fix): fixed an internal error when using aggregates
and window functions in an ORDER BY for a UNION or VALUES clause.
@RaduBerinde RaduBerinde requested a review from a team as a code owner December 3, 2020 23:08
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@RaduBerinde RaduBerinde merged commit 5863710 into cockroachdb:release-20.2 Dec 4, 2020
@RaduBerinde RaduBerinde deleted the backport20.2-57498 branch December 4, 2020 03:05
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