Surface a user friendly error when PARTITIONED BY is omitted#12246
Merged
abhishekagarwal87 merged 4 commits intoapache:masterfrom Feb 11, 2022
Merged
Surface a user friendly error when PARTITIONED BY is omitted#12246abhishekagarwal87 merged 4 commits intoapache:masterfrom
abhishekagarwal87 merged 4 commits intoapache:masterfrom
Conversation
gianm
reviewed
Feb 9, 2022
Contributor
gianm
left a comment
There was a problem hiding this comment.
The change looks good, just had a comment on the error message.
| ); | ||
| Preconditions.checkNotNull(partitionedBy); // Shouldn't hit due to how the parser is written | ||
| if (partitionedBy == null) { | ||
| throw new ParseException("INSERT statements should specify PARTITIONED BY clause explictly"); |
Contributor
There was a problem hiding this comment.
The word "must" is better than "should" here. (RFC 2119 doesn't govern here, but is still a helpful guide for technical writing. "Should" means "recommended, but not strictly required".)
Contributor
Author
There was a problem hiding this comment.
Updated the error message. Thanks for the tip.
| * While partitionedBy and partitionedByStringForUnparse can be null as arguments to the constructor, this is | ||
| * disallowed (semantically) and the constructor performs checks to ensure that. This helps in producing friendly | ||
| * errors when the PARTITIONED BY custom clause is not present, and keeps its error separate from JavaCC/Calcite's | ||
| * custom errors which can be cryptic when someone accidentaly forgets to explicitly specify the PARTITIONED BY clause |
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.
Description
#12163 makes
PARTITIONED BYa required clause in INSERT queries. While this is required, if a user accidentally omits the clause, it emits a JavaCC/Calcite error, since it's syntactically incorrect. The error message is cryptic. Since it's a custom clause, this PR aims to make the clause optional on the syntactic side, but move the validation toDruidSqlInsertwhere we can surface a friendlier error.Also, to specify insert granularity as ALL, one can either mention
ALL TIME(as in the original proposal) orALL(after the change).Key changed/added classes in this PR
insert.ftlDruidSqlInsertThis PR has: