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/11/23 09:18:36 UTC

[GitHub] [calcite] danny0405 commented on a change in pull request #2272: [CALCITE-4409] Improve exception when RelBuilder tries to create a field on a non-struct expression

danny0405 commented on a change in pull request #2272:
URL: https://github.com/apache/calcite/pull/2272#discussion_r528559816



##########
File path: core/src/main/java/org/apache/calcite/tools/RelBuilder.java
##########
@@ -495,6 +495,10 @@ public RexNode field(int inputCount, String alias, String fieldName) {
 
   /** Returns a reference to a given field of a record-valued expression. */
   public RexNode field(RexNode e, String name) {
+    if (!e.getType().isStruct()) {
+      throw new IllegalArgumentException("Requested field " + name + " in non-struct expression "
+          + e.toString() + " (type: " + e.getType() + ")");
+    }

Review comment:
       I have the impression that the `RelBuilder` build rel trees based on all kinds of assumptions, it assumes that the invoker knows how to behave with the valid operands. We may need to check all the interfaces in `RelBuilder`, this PR is a good start.




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