[ 
https://issues.apache.org/jira/browse/CALCITE-6813?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17924374#comment-17924374
 ] 

Mihai Budiu commented on CALCITE-6813:
--------------------------------------

I am reopening this issue, because my fix for it was actually incorrect.
I have overlooked the following aspect:
When the array itself is null, the result of uncollect is an empty collection.
Thus the nullability of the array itself does not change the result type of 
uncollect.
Only the case when elements are ROW types that may be nullable should have been 
fixed.
I will submit another PR and write more tests.


> UNNEST infers incorrect nullability for the result when applied to an array 
> that contains nullable ROW values
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-6813
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6813
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.38.0
>            Reporter: Mihai Budiu
>            Assignee: Mihai Budiu
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 1.39.0
>
>
> An array can have nullable elements, which can be ROW values.
> Consider this example, validated in Postgres:
> {code:sql}
> CREATE TYPE person AS (
>     id INTEGER,
>     name TEXT
> );
> CREATE TABLE example_table (
>     id SERIAL PRIMARY KEY,
>     data person[]
> );
> SELECT (element).id AS name
> FROM example_table,
> UNNEST(data) AS element;
> {code}
> If an element in the array is null, then the corresponding element.id is also 
> null. 
> However, Calcite infers a type of RecordType(BIGINT id) for the rows of this 
> query, which is non-nullable.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to