You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2019/07/15 13:29:26 UTC

[GitHub] [calcite] danny0405 commented on a change in pull request #1276: [CALCITE-3137] AssertionError when reconstructing STRUCTURED type fields

danny0405 commented on a change in pull request #1276: [CALCITE-3137] AssertionError when reconstructing STRUCTURED type fields
URL: https://github.com/apache/calcite/pull/1276#discussion_r303434966
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/sql/fun/SqlNewOperator.java
 ##########
 @@ -49,6 +50,14 @@ public SqlNode rewriteCall(SqlValidator validator, SqlCall call) {
   public boolean requiresDecimalExpansion() {
     return false;
   }
+
+  @Override public boolean validRexOperands(int count, Litmus litmus) {
+    if (count <= 0) {
+      return litmus.fail("wrong operand count {} for {}, Need at least one RexOperand!",
+          count, this);
+    }
+    return litmus.succeed();
+  }
 
 Review comment:
   Here is the java doc of `SqlNewOperator`:
   >SqlNewOperator represents an SQL <code>new specification</code> such as
   <code>NEW UDT(1, 2)</code>. When used in an SqlCall, SqlNewOperator takes a
   single operand, which is an invocation of the constructor method; but when
   used in a RexCall, the operands are the initial values to be used for the new
   instance.
   
   The `validRexOperands` method is only invoked in `RexCall` constructor, so i think overriding is the right way to go. But why we must require the count bigger than 0, how about there is a user defined constructor without any operands ? 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services