[ 
https://issues.apache.org/jira/browse/FLINK-40672?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Timo Walther closed FLINK-40672.
--------------------------------
    Fix Version/s: 2.4.0
         Assignee: dylanhz
       Resolution: Fixed

Fixed in master: 4a23ab12063d4d1354fae905f01e47b9777c402e

> Incorrect nullability for CAST from VARIANT
> -------------------------------------------
>
>                 Key: FLINK-40672
>                 URL: https://issues.apache.org/jira/browse/FLINK-40672
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / API
>            Reporter: dylanhz
>            Assignee: dylanhz
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 2.4.0
>
>
> h3. Description
> A non-nullable VARIANT can contain a variant null. Casting it to a 
> non-VARIANT type returns SQL NULL, but Flink incorrectly infers a NOT NULL 
> result.
> For example:
> {code:sql}
> SELECT CAST(PARSE_JSON('null') AS INT);
> {code}
> This can cause runtime NOT NULL violations or incorrect optimization of {{IS 
> NULL}} and {{COALESCE}}.
> Upstream Calcite already correctly makes casts from VARIANT to non-VARIANT 
> types nullable. Flink's copied {{SqlCastFunction}} does not preserve this 
> behavior.
> h3. Expected behavior
> Align with Calcite and consistently infer nullable results for casts from 
> VARIANT to non-VARIANT types in both SQL and Table API.



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

Reply via email to