You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "dylanhz (Jira)" <ji...@apache.org> on 2026/09/15 12:30:00 UTC

[jira] [Created] (FLINK-40672) Incorrect nullability for CAST from VARIANT

dylanhz created FLINK-40672:
-------------------------------

             Summary: 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


*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:

 

{{SELECT CAST(PARSE_JSON('null') AS INT);}}

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.

*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)