rubenada commented on a change in pull request #2272:
URL: https://github.com/apache/calcite/pull/2272#discussion_r528627634
##########
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 proposed `IllegalArgumentException`, considering the first argument to
be the illegal one (`RexNode expr`, having a non-struct type). But I can see
`IllegalStateException` fitting here as well.
@zabetak @danny0405 what are your thoughts regarding the new proposal? Are
you against adding the check in `RexBuilder#makefieldAccess` (hence having an
`AssertionError` from `RelDataTypleImpl`); or for adding check (in which case,
would you see it as an `IllegalArgumentException` or `IllegalStateException`)?
----------------------------------------------------------------
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:
[email protected]