[
https://issues.apache.org/jira/browse/CALCITE-6764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17912716#comment-17912716
]
Mihai Budiu commented on CALCITE-6764:
--------------------------------------
Problems arise when trying to support tables with nested ROW types, e.g.,
{code:sql}
CREATE TABLE T(q ROW(s ROW(l VARCHAR NOT NULL) NULL) NULL);
{code}
The typechecking code cannot use the factory to create an appropriate type for
t.q.s.
> Field access from a nullable ROW should be nullable
> ---------------------------------------------------
>
> Key: CALCITE-6764
> URL: https://issues.apache.org/jira/browse/CALCITE-6764
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.38.0
> Reporter: Mihai Budiu
> Assignee: Mihai Budiu
> Priority: Minor
> Labels: pull-request-available
>
> Consider the following SQL:
> {code:sql}
> CREATE TABLE T(p MAP<VARCHAR, ROW(k VARCHAR, v VARCHAR)>);
> SELECT p['a'].k FROM T;
> {code}
> The MAP values are ROW values, which can be null.
> The type of p['a'] is nullable, so p['a'].k should also be nullable.
> The validator will crash while validating this query with the following error:
> {code}
> java.lang.RuntimeException: java.lang.AssertionError: Conversion to
> relational algebra failed to preserve datatypes:
> validated type:
> RecordType(VARCHAR EXPR$0) NOT NULL
> converted type:
> RecordType(VARCHAR NOT NULL EXPR$0) NOT NULL
> rel:
> LogicalProject(EXPR$0=[ITEM($0, 'a').k])
> LogicalTableScan(table=[[schema, t]])
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)