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

sql: disable order by index in aggregate decoration clauses #109861

Merged

Conversation

rharding6373
Copy link
Collaborator

Before this change, queries like SELECT percentile_disc ( 0.50 ) WITHIN GROUP ( ORDER BY PRIMARY KEY tbl ) FROM tbl; would fail with an internal error. This is due to optbuilder expecting an order expression, which order by index does not provide, in the aggregate case in order to resolve the function.

Since this functionality has never worked and appears to be a rare or never used feature, this PR disables queries with order by index in this position at the parsing stage. Issue #109847 has been opened to track usage.

Epic: None
Fixes: #109069
Informs: #109847

Release note: None.

Before this change, queries like `SELECT percentile_disc ( 0.50 ) WITHIN
GROUP ( ORDER BY PRIMARY KEY tbl ) FROM tbl;` would fail with an
internal error. This is due to optbuilder expecting an order expression,
which order by index does not provide, in the aggregate case in order to
resolve the function.

Since this functionality has never worked and appears to be a rare or
never used feature, this PR disables queries with order by index in this
position at the parsing stage. Issue cockroachdb#109847 has been opened to track
usage.

Epic: None
Fixes: cockroachdb#109069
Informs: cockroachdb#109847

Release note: None.
@rharding6373 rharding6373 requested review from a team and removed request for a team August 31, 2023 23:54
@rharding6373 rharding6373 requested a review from a team as a code owner August 31, 2023 23:54
@blathers-crl
Copy link

blathers-crl bot commented Aug 31, 2023

It looks like your PR touches SQL parser code but doesn't add or edit parser tests. Please make sure you add or edit parser tests if you edit the parser.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

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

:lgtm: Nicely done!

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

@rharding6373
Copy link
Collaborator Author

TFTR!

bors r+

@craig
Copy link
Contributor

craig bot commented Sep 5, 2023

Build succeeded:

@rharding6373
Copy link
Collaborator Author

blathers backport 23.1

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.

sql/tests: TestRandomSyntaxFuncCommon failed [nil pointer in optbuilder]
3 participants