[
https://issues.apache.org/jira/browse/CALCITE-6920?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17939081#comment-17939081
]
Mihai Budiu commented on CALCITE-6920:
--------------------------------------
A similar issue exists for MAP types.
There it's somewhat less clear what the type inferred for the cast should be.
Can keys in a map be nullable?
> The type derived for a cast to INT ARRAY always has non-nullable elements
> -------------------------------------------------------------------------
>
> Key: CALCITE-6920
> URL: https://issues.apache.org/jira/browse/CALCITE-6920
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.39.0
> Reporter: Mihai Budiu
> Assignee: Mihai Budiu
> Priority: Minor
>
> Consider an expression such as SELECT CAST(variant AS INT ARRAY).
> The type inference produces a type of INTEGER NOT NULL ARRAY.
> This is incorrect, since the elements of the array could be nulls.
> This happens because SqlCollectionTypeNameSpec.deriveType never produces
> nullable types for collection elements.
> Notice that one cannot write INT NULL ARRAY or INT NOT NULL ARRAY.
> A conservative implementation should always produce a nullable element type.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)