Fail query planning if a CLUSTERED BY column contains descending order#14436
Merged
zachjsh merged 7 commits intoapache:masterfrom Jun 16, 2023
Merged
Fail query planning if a CLUSTERED BY column contains descending order#14436zachjsh merged 7 commits intoapache:masterfrom
CLUSTERED BY column contains descending order#14436zachjsh merged 7 commits intoapache:masterfrom
Conversation
CLUSTERED BY column contains descending orderCLUSTERED BY column contains descending order
32ca25d to
32a9bbf
Compare
cryptoe
approved these changes
Jun 16, 2023
Contributor
cryptoe
left a comment
There was a problem hiding this comment.
LGTM. Thanks @abhishekrb19
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this change, queries will successfully plan if any
CLUSTERED BYcolumn contains aDESCorder. MSQE will validate that after the plan is generated and throw anInsertCannotOrderByDescendingfault. This deferred validation makes it hard for clients that rely on whether a query can be successfully planned or not.Now with this change, the validation is pushed down to the planning stage as a sql validation step. So the query planning will fail with a
ValidationExceptionif anINSERTorREPLACEquery contains one or more clustering columns with descending order.Release note
The MSQ fault,
InsertCannotOrderByDescending, is marked deprecated. An INSERT or REPLACE query containing aCLUSTERED BYexpression cannot be in descending order. Druid's segment generation code only supports ascending order. A queryValidationExceptionis thrown instead of the fault in this scenario.Key changed/added classes in this PR
DruidSqlParserUtils.javaInsertCannotOrderByDescendingFault.javaASCinstead ofDESC; add new tests withDESCwhere the thrown exception is validated.This PR has: