abhishekrb19 opened a new pull request, #15961:
URL: https://github.com/apache/druid/pull/15961
Prior to this patch, an incorrect `PARTITIONED BY` clause can expose options
like `NONE` in the returned error message:
```
Invalid granularity[foo] specified after PARTITIONED BY clause. Expected
SECOND, MINUTE, FIVE_MINUTE, TEN_MINUTE, FIFTEEN_MINUTE, THIRTY_MINUTE, HOUR,
SIX_HOUR, EIGHT_HOUR, DAY, MONTH, QUARTER, YEAR, ALL, NONE, ALL TIME, FLOOR()
or TIME_FLOOR()
```
Also, some of these granularities like `MINUTE` and `QUARTER` are reserved
SQL keywords that are not handled explicitly in Druid. In order for them to be
properly used they should be quoted as literals. So single quote the
granularity literals in the error message making it clear to a user about the
correct usage.
Other related changes:
- A general overall clean up of `DruidSqlParserUtils.java`:
- A mix of Precondition checks, ValidationException and DruidException
were thrown making the calling code catch these different exceptions and unify
them. So migrate all the exception handling usages in this class to
DruidException and add additional context to messages as needed.
- Remove unused method, modify a few method access modifiers,
removed/added `@VisibleForTesting`, etc.
- Added a couple of tests for the literal granularity case noted above.
- Fix up some typos and inaccuracies in the javadocs for the partitioned by
area of code.
##### Key changed/added classes in this PR
* `DruidSqlParserUtils.java`
* `DruidSqlParserUtilsTest.java`
<hr>
<!-- Check the items by putting "x" in the brackets for the done things. Not
all of these items apply to every PR. Remove the items which are not done or
not relevant to the PR. None of the items from the checklist below are strictly
necessary, but it would be very helpful if you at least self-review the PR. -->
This PR has:
- [x] been self-reviewed.
- [x] added Javadocs for most classes and all non-trivial methods. Linked
related entities via Javadoc links.
- [x] added unit tests or modified existing tests to cover new code paths,
ensuring the threshold for [code
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
is met.
- [x] been tested in a test Druid cluster.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]