-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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-22.1: opt: add support for NULLS LAST with DISTINCT ON #93608
Conversation
34fbc2f
to
62dac05
Compare
Thanks for opening a backport. Please check the backport criteria before merging:
If some of the basic criteria cannot be satisfied, ensure that the exceptional criteria are satisfied within.
Add a brief release justification to the body of your PR to justify this backport. Some other things to consider:
|
Let's hold off on merging this backport until #93719 is fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @michae2 and @rytaft)
fb5d660
to
50a7cb1
Compare
This commit adds an exception for the requirement that the ORDER BY clause of a DISTINCT ON query must contain only columns in the ON clause. Specifically, it allows expressions of the form `col IS NULL`, where col is one of the ON columns. This is needed to support NULLS LAST, since we implement NULLS LAST by synthesizing a `col IS NULL` ordering column. The approach feels a bit hacky, but it seems like the smallest, lowest risk option available. Fixes #90763 Release note (bug fix): Fixed an issue where DISTINCT ON queries would fail with the error "SELECT DISTINCT ON expressions must match initial ORDER BY expressions" when the query included an ORDER BY clause containing ASC NULLS LAST or DESC NULLS FIRST.
50a7cb1
to
ce7c5c0
Compare
Backport 1/1 commits from #93567 on behalf of @rytaft.
/cc @cockroachdb/release
This commit adds an exception for the requirement that the
ORDER BY
clause of aDISTINCT ON
query must contain only columns in theON
clause. Specifically, it allows expressions of the formcol IS NULL
, wherecol
is one of theON
columns. This is needed to supportNULLS LAST
, since we implementNULLS LAST
by synthesizing acol IS NULL
ordering column.The approach feels a bit hacky, but it seems like the smallest, lowest risk option available.
Fixes #90763
Release note (bug fix): Fixed an issue where
DISTINCT ON
queries would fail with the error "SELECT DISTINCT ON expressions must match initial ORDER BY expressions" when the query included anORDER BY
clause containingASC NULLS LAST
orDESC NULLS FIRST
.Release justification: Low-risk bug fix.