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/02/09 20:43:48 UTC

[GitHub] [druid] gianm commented on a change in pull request #12246: Surface a user friendly error when PARTITIONED BY is omitted

gianm commented on a change in pull request #12246:
URL: https://github.com/apache/druid/pull/12246#discussion_r803071379



##########
File path: sql/src/main/java/org/apache/druid/sql/calcite/parser/DruidSqlInsert.java
##########
@@ -62,10 +68,14 @@ public DruidSqlInsert(
         insertNode.getSource(),
         insertNode.getTargetColumnList()
     );
-    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");

Review 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".)

##########
File path: sql/src/main/java/org/apache/druid/sql/calcite/parser/DruidSqlInsert.java
##########
@@ -48,12 +48,18 @@
   @Nullable
   private final SqlNodeList clusteredBy;
 
+  /**
+   * 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

Review comment:
       accidentally (spelling)




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