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 2020/07/29 07:27:43 UTC

[GitHub] [calcite] danny0405 opened a new pull request #2088: [CALCITE-4145] Exception when query from UDF field with structured type

danny0405 opened a new pull request #2088:
URL: https://github.com/apache/calcite/pull/2088


   


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



[GitHub] [calcite] zinking commented on pull request #2088: [CALCITE-4145] Exception when query from UDF field with structured type

Posted by GitBox <gi...@apache.org>.
zinking commented on pull request #2088:
URL: https://github.com/apache/calcite/pull/2088#issuecomment-664977245


   looks good


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



[GitHub] [calcite] danny0405 merged pull request #2088: [CALCITE-4145] Exception when query from UDF field with structured type

Posted by GitBox <gi...@apache.org>.
danny0405 merged pull request #2088:
URL: https://github.com/apache/calcite/pull/2088


   


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



[GitHub] [calcite] danny0405 commented on a change in pull request #2088: [CALCITE-4145] Exception when query from UDF field with structured type

Posted by GitBox <gi...@apache.org>.
danny0405 commented on a change in pull request #2088:
URL: https://github.com/apache/calcite/pull/2088#discussion_r461515305



##########
File path: core/src/main/java/org/apache/calcite/rex/RexFieldAccess.java
##########
@@ -57,14 +59,23 @@
   RexFieldAccess(
       RexNode expr,
       RelDataTypeField field) {
+    checkValid(expr, field);
     this.expr = expr;
     this.field = field;
     this.digest = expr + "." + field.getName();
-    assert expr.getType().getFieldList().get(field.getIndex()) == field;
   }
 
   //~ Methods ----------------------------------------------------------------
 
+  private static void checkValid(RexNode expr, RelDataTypeField field) {
+    RelDataType exprType = expr.getType();
+    int fieldsNum = exprType.getFieldList().size();
+    int fieldIdx = field.getIndex();
+    final String errMsg = "Field " + field + " does not exist for expression " + expr;
+    Preconditions.checkArgument(fieldIdx < fieldsNum, errMsg);
+    Preconditions.checkArgument(exprType.getFieldList().get(fieldIdx).equals(field), errMsg);
+  }

Review comment:
       I made this change because there are some problem with the new added test case in test env with concurrency, the `==` check is invalid.

##########
File path: core/src/main/java/org/apache/calcite/rex/RexFieldAccess.java
##########
@@ -57,14 +59,23 @@
   RexFieldAccess(
       RexNode expr,
       RelDataTypeField field) {
+    checkValid(expr, field);
     this.expr = expr;
     this.field = field;
     this.digest = expr + "." + field.getName();
-    assert expr.getType().getFieldList().get(field.getIndex()) == field;
   }
 
   //~ Methods ----------------------------------------------------------------
 
+  private static void checkValid(RexNode expr, RelDataTypeField field) {
+    RelDataType exprType = expr.getType();
+    int fieldsNum = exprType.getFieldList().size();
+    int fieldIdx = field.getIndex();
+    final String errMsg = "Field " + field + " does not exist for expression " + expr;
+    Preconditions.checkArgument(fieldIdx < fieldsNum, errMsg);
+    Preconditions.checkArgument(exprType.getFieldList().get(fieldIdx).equals(field), errMsg);
+  }

Review comment:
       I made this change because there are some problem with the new added test case in test env with concurrency, the `==` check not works anymore.




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