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/26 11:25:00 UTC
[jira] [Resolved] (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 resolved CALCITE-4409.
--------------------------------
Resolution: Fixed
Fixed via https://github.com/apache/calcite/commit/fc912eb19d9ebbaee843dc1e9d3b4175e757cb53
> 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: Trivial
> Labels: pull-request-available
> Fix For: 1.27.0
>
> Time Spent: 7h 10m
> Remaining Estimate: 0h
>
> 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 (IllegalArgumentException) and a more useful exception message.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)