[
https://issues.apache.org/jira/browse/CALCITE-7358?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ASF GitHub Bot updated CALCITE-7358:
------------------------------------
Labels: pull-request-available (was: )
> Casts involving MAP and ROW types cause compile-time exceptions
> ---------------------------------------------------------------
>
> Key: CALCITE-7358
> URL: https://issues.apache.org/jira/browse/CALCITE-7358
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.41.0
> Reporter: Mihai Budiu
> Assignee: Mihai Budiu
> Priority: Minor
> Labels: pull-request-available
>
> Here are two examples which would fail in server/type.iq:
> {code:java}
> CREATE TYPE user_def AS(i1 INT, v1 VARCHAR NULL);
> CREATE TABLE tbl(mapp1 MAP<user_def, ROW(v VARCHAR NULL)>);
> SELECT CAST(mapp1[0] AS INT) FROM tbl;
> SELECT CAST(mapp1 AS MAP<VARCHAR, INT>) AS to_map FROM tbl; {code}
> There are two exceptions: an assertion failure, and a null pointer exception:
> {code:java}
> > Caused by: java.lang.NullPointerException:
> > keyType.getSqlTypeName().getFamily() null, type is ROW
> > at java.base/java.util.Objects.requireNonNull(Objects.java:360)
> > at
> > org.apache.calcite.sql.fun.SqlItemOperator.getChecker(SqlItemOperator.java:168)
> > at
> > org.apache.calcite.sql.fun.SqlItemOperator.checkOperandTypes(SqlItemOperator.java:104)
> > at
> > org.apache.calcite.sql.SqlOperator.validateOperands(SqlOperator.java:526)
> > at org.apache.calcite.sql.SqlOperator.deriveType(SqlOperator.java:631)
> > at
> > org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:7219)
> > at
> > org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:7206)
> >
> {code}
> and
> {code:java}
> > java.lang.AssertionError: fieldList must not be null, type = VARCHAR
> > at
> > org.apache.calcite.rel.type.RelDataTypeImpl.getFieldList(RelDataTypeImpl.java:193)
> > at
> > org.apache.calcite.sql.fun.SqlCastFunction.createTypeWithNullabilityFromExpr(SqlCastFunction.java:176)
> > at
> > org.apache.calcite.sql.fun.SqlCastFunction.createTypeWithNullabilityFromExpr(SqlCastFunction.java:198)
> > at
> > org.apache.calcite.sql.fun.SqlCastFunction.deriveType(SqlCastFunction.java:138)
> > at
> > org.apache.calcite.sql.fun.SqlCastFunction.lambda$returnTypeInference$0(SqlCastFunction.java:117)
> > at
> > org.apache.calcite.sql.SqlOperator.inferReturnType(SqlOperator.java:562)
> > at
> > org.apache.calcite.sql.SqlOperator.validateOperands(SqlOperator.java:531)
> > at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:350)
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)