You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2022/05/21 15:00:32 UTC
[GitHub] [druid] adarshsanjeev opened a new pull request, #12558: Add error message for incorrectly ordered clause in sql
adarshsanjeev opened a new pull request, #12558:
URL: https://github.com/apache/druid/pull/12558
- Add error message for incorrectly ordered clause in sql
- Add unit tests to verify
<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.
- [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
- [ ] added documentation for new or modified features or behaviors.
- [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
- [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
- [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
- [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.
- [ ] added integration tests.
- [ ] 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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] LakshSingla commented on a diff in pull request #12558: Add error message for incorrectly ordered clause in sql
Posted by GitBox <gi...@apache.org>.
LakshSingla commented on code in PR #12558:
URL: https://github.com/apache/druid/pull/12558#discussion_r879032944
##########
sql/src/main/codegen/includes/insert.ftl:
##########
@@ -36,6 +36,11 @@ SqlNode DruidSqlInsertEof() :
<CLUSTERED> <BY>
clusteredBy = ClusterItems()
]
+ {
+ if (clusteredBy != null && partitionedBy.lhs == null) {
+ throw new ParseException("CLUSTERED BY clause found before PARTITIONED BY, the PARITITIONED BY clause has to be specified first before the CLUSTERED BY clause.");
+ }
+ }
Review Comment:
Since this is an error/check on the parsing side, it seems more in tune with Calcite's Parser.jj where the parsing errors are thrown from the .jj file itself. From a functional standpoint, they are equivalent. (It might be beneficial to throw the error before creating a node in some cases, but I don't think they apply here)
##########
sql/src/main/codegen/includes/insert.ftl:
##########
@@ -36,6 +36,11 @@ SqlNode DruidSqlInsertEof() :
<CLUSTERED> <BY>
clusteredBy = ClusterItems()
]
+ {
+ if (clusteredBy != null && partitionedBy.lhs == null) {
+ throw new ParseException("CLUSTERED BY clause found before PARTITIONED BY, the PARITITIONED BY clause has to be specified first before the CLUSTERED BY clause.");
+ }
+ }
Review Comment:
Since this is an error/check on the parsing side, it seems more in tune with Calcite's Parser.jj where the parsing errors are thrown from the .jj file itself. From a functional standpoint, they are equivalent. (It might be beneficial to throw the error before creating a node in some cases, but I don't think they apply here).
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] abhishekagarwal87 merged pull request #12558: Add error message for incorrectly ordered clause in sql
Posted by GitBox <gi...@apache.org>.
abhishekagarwal87 merged PR #12558:
URL: https://github.com/apache/druid/pull/12558
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] LakshSingla commented on a diff in pull request #12558: Add error message for incorrectly ordered clause in sql
Posted by GitBox <gi...@apache.org>.
LakshSingla commented on code in PR #12558:
URL: https://github.com/apache/druid/pull/12558#discussion_r879027522
##########
sql/src/main/codegen/includes/insert.ftl:
##########
@@ -36,6 +36,11 @@ SqlNode DruidSqlInsertEof() :
<CLUSTERED> <BY>
clusteredBy = ClusterItems()
]
+ {
+ if (clusteredBy != null && partitionedBy.lhs == null) {
+ throw new ParseException("CLUSTERED BY clause found before PARTITIONED BY, the PARITITIONED BY clause has to be specified first before the CLUSTERED BY clause.");
+ }
+ }
Review Comment:
This does seem alright, my one concern is that .ftl files are not supported by default (or using free plugins) in Intellij (community edition). As we move more java code to ftl, it might be difficult to keep a check on them. Is that something that we should take into consideration?
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] cryptoe commented on a diff in pull request #12558: Add error message for incorrectly ordered clause in sql
Posted by GitBox <gi...@apache.org>.
cryptoe commented on code in PR #12558:
URL: https://github.com/apache/druid/pull/12558#discussion_r878765879
##########
sql/src/main/codegen/includes/insert.ftl:
##########
@@ -36,6 +36,11 @@ SqlNode DruidSqlInsertEof() :
<CLUSTERED> <BY>
clusteredBy = ClusterItems()
]
+ {
+ if (clusteredBy != null && partitionedBy.lhs == null) {
+ throw new ParseException("CLUSTERED BY clause found before PARTITIONED BY, the PARITITIONED BY clause has to be specified first before the CLUSTERED BY clause.");
Review Comment:
```suggestion
throw new ParseException("CLUSTERED BY found before PARTITIONED BY. In druid, the CLUSTERED BY clause has to be specified after the PARTITIONED BY clause");
```
##########
sql/src/main/codegen/includes/replace.ftl:
##########
@@ -56,6 +56,11 @@ SqlNode DruidSqlReplaceEof() :
<CLUSTERED> <BY>
clusteredBy = ClusterItems()
]
+ {
+ if (clusteredBy != null && partitionedBy.lhs == null) {
+ throw new ParseException("CLUSTERED BY clause found before PARTITIONED BY, the PARITITIONED BY clause has to be specified first before the CLUSTERED BY clause.");
Review Comment:
```suggestion
throw new ParseException("CLUSTERED BY found before PARTITIONED BY. In druid, the CLUSTERED BY clause has to be specified after the PARTITIONED BY clause);
```
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] abhishekagarwal87 commented on a diff in pull request #12558: Add error message for incorrectly ordered clause in sql
Posted by GitBox <gi...@apache.org>.
abhishekagarwal87 commented on code in PR #12558:
URL: https://github.com/apache/druid/pull/12558#discussion_r879029863
##########
sql/src/main/codegen/includes/insert.ftl:
##########
@@ -36,6 +36,11 @@ SqlNode DruidSqlInsertEof() :
<CLUSTERED> <BY>
clusteredBy = ClusterItems()
]
+ {
+ if (clusteredBy != null && partitionedBy.lhs == null) {
+ throw new ParseException("CLUSTERED BY clause found before PARTITIONED BY, the PARITITIONED BY clause has to be specified first before the CLUSTERED BY clause.");
+ }
+ }
Review Comment:
what is the advantage of keeping a check here instead of keeping it in the java code?
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] adarshsanjeev commented on a diff in pull request #12558: Add error message for incorrectly ordered clause in sql
Posted by GitBox <gi...@apache.org>.
adarshsanjeev commented on code in PR #12558:
URL: https://github.com/apache/druid/pull/12558#discussion_r878705039
##########
sql/src/main/codegen/includes/insert.ftl:
##########
@@ -36,6 +36,11 @@ SqlNode DruidSqlInsertEof() :
<CLUSTERED> <BY>
clusteredBy = ClusterItems()
]
+ {
+ if (clusteredBy != null && partitionedBy.lhs == null) {
+ throw new ParseException("CLUSTERED BY clause found before PARTITIONED BY, the PARITITIONED BY clause has to be specified first before the CLUSTERED BY clause.");
+ }
+ }
Review Comment:
@LakshSingla if this approach looks alright, it would be possible to move some of the other checks here as well.
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] LakshSingla commented on pull request #12558: Add error message for incorrectly ordered clause in sql
Posted by GitBox <gi...@apache.org>.
LakshSingla commented on PR #12558:
URL: https://github.com/apache/druid/pull/12558#issuecomment-1134184799
Thanks for the PR! Can you please update the description to be more descriptive?
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
[GitHub] [druid] adarshsanjeev commented on a diff in pull request #12558: Add error message for incorrectly ordered clause in sql
Posted by GitBox <gi...@apache.org>.
adarshsanjeev commented on code in PR #12558:
URL: https://github.com/apache/druid/pull/12558#discussion_r879037275
##########
sql/src/main/codegen/includes/insert.ftl:
##########
@@ -36,6 +36,11 @@ SqlNode DruidSqlInsertEof() :
<CLUSTERED> <BY>
clusteredBy = ClusterItems()
]
+ {
+ if (clusteredBy != null && partitionedBy.lhs == null) {
+ throw new ParseException("CLUSTERED BY clause found before PARTITIONED BY, the PARITITIONED BY clause has to be specified first before the CLUSTERED BY clause.");
+ }
+ }
Review Comment:
Partitioned by is nullable in the insert and replace classes, we can make that a non null to make it cleaner if we move the null check here.
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org