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



##########
File path: core/src/test/java/org/apache/calcite/test/RelBuilderTest.java
##########
@@ -2577,6 +2577,22 @@ private RelNode buildRelWithDuplicateAggregates(
     assertThat(ex.getMessage(), allOf(containsString("Expression"), 
containsString("not found")));
   }
 
+  /** Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-4409";>[CALCITE-4409]
+   * Improve exception when RelBuilder tries to create a field on a non-struct 
expression</a>. */
+  @Test void testFieldOnNonStructExpression() {
+    final RelBuilder builder = RelBuilder.create(config().build());
+    IllegalStateException ex = assertThrows(IllegalStateException.class, () -> 
{
+      builder.scan("EMP")
+          .project(
+              builder.field(builder.field("EMPNO"), "abc"))
+          .build();
+    }, "Field should fail since we are trying access a field on expression 
with non-struct type");
+    assertThat(ex.getMessage(),
+        allOf(containsString("Trying to access field"),
+            containsString("in a type with no fields")));

Review comment:
       Ok, changed.




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


Reply via email to