You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Ruben Q L (Jira)" <ji...@apache.org> on 2020/11/19 15:45:00 UTC

[jira] [Assigned] (CALCITE-4409) Improve exception when RelBuilder tries to create a field on a non-struct expression

     [ https://issues.apache.org/jira/browse/CALCITE-4409?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ruben Q L reassigned CALCITE-4409:
----------------------------------

    Assignee: Ruben Q L

> Improve exception when RelBuilder tries to create a field on a non-struct expression
> ------------------------------------------------------------------------------------
>
>                 Key: CALCITE-4409
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4409
>             Project: Calcite
>          Issue Type: Task
>          Components: core
>            Reporter: Ruben Q L
>            Assignee: Ruben Q L
>            Priority: Major
>             Fix For: 1.27.0
>
>
> 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:
> {code}
>   @Test void test() {
>     final RelBuilder builder = RelBuilder.create(config().build());
>     builder.scan("EMP")
>         .project(
>             builder.field(builder.field("EMPNO"), "abc"))
>         .build();
>   }
> {code}
> Fails with a NPE:
> {noformat}
> 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)
> {noformat}
> This situation could be handled with a more gracefully exit and a more useful exception message.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)