Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-4409

Improve exception when RelBuilder tries to create a field on a non-struct expression

    XMLWordPrintableJSON

    Details

      Description

      A simple test like this (to added in RelBuilderTest), where RelBuilder#field(RexNode e, String name) is called and the first parameter's type is not a struct:

        @Test void test() {
          final RelBuilder builder = RelBuilder.create(config().build());
          builder.scan("EMP")
              .project(
                  builder.field(builder.field("EMPNO"), "abc"))
              .build();
        }
      

      Fails with a NPE:

      java.lang.NullPointerException
      	at org.apache.calcite.rel.type.RelDataTypeImpl.getField(RelDataTypeImpl.java:82)
      	at org.apache.calcite.rex.RexBuilder.makeFieldAccess(RexBuilder.java:182)
      	at org.apache.calcite.tools.RelBuilder.field(RelBuilder.java:502)
      

      This situation could be handled with a more gracefully exit (IllegalArgumentException) and a more useful exception message.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rubenql Ruben Q L
                Reporter:
                rubenql Ruben Q L
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 7h 20m
                  7h 20m