[
https://issues.apache.org/jira/browse/FLINK-40182?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sergey Nuyanzin updated FLINK-40182:
------------------------------------
Description:
{{ArrayToArrayCastRule}}, {{MapToMapAndMultisetToMultisetCastRule}} generate
code that trusted the target type's declared NOT NULL nullability instead of
checking the actual runtime value. When the source array/map element was
actually null (a cast doesn't enforce constraints, so a NOT NULL target type is
not a runtime guarantee), the generated code would either throw an NPE (e.g.,
unboxing a null) or, for primitive-backed arrays, silently write a default
value (e.g., 0) instead of preserving/rejecting the null — masking data
corruption.
repro
{code:sql}
SELECT CAST(ARRAY[ARRAY[1, CAST(NULL AS BIGINT)]] AS ARRAY<ARRAY<BIGINT NOT
NULL> NOT NULL>)
{code}
was:{{ArrayToArrayCastRule}}, {{MapToMapAndMultisetToMultisetCastRule}}
generate code that trusted the target type's declared NOT NULL nullability
instead of checking the actual runtime value. When the source array/map element
was actually null (a cast doesn't enforce constraints, so a NOT NULL target
type is not a runtime guarantee), the generated code would either throw an NPE
(e.g., unboxing a null) or, for primitive-backed arrays, silently write a
default value (e.g., 0) instead of preserving/rejecting the null — masking data
corruption.
> ArrayToArray and MapToMap cast rules generate code which might fail with NPE
> ----------------------------------------------------------------------------
>
> Key: FLINK-40182
> URL: https://issues.apache.org/jira/browse/FLINK-40182
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / Planner
> Reporter: Sergey Nuyanzin
> Assignee: Sergey Nuyanzin
> Priority: Major
>
> {{ArrayToArrayCastRule}}, {{MapToMapAndMultisetToMultisetCastRule}} generate
> code that trusted the target type's declared NOT NULL nullability instead of
> checking the actual runtime value. When the source array/map element was
> actually null (a cast doesn't enforce constraints, so a NOT NULL target type
> is not a runtime guarantee), the generated code would either throw an NPE
> (e.g., unboxing a null) or, for primitive-backed arrays, silently write a
> default value (e.g., 0) instead of preserving/rejecting the null — masking
> data corruption.
> repro
> {code:sql}
> SELECT CAST(ARRAY[ARRAY[1, CAST(NULL AS BIGINT)]] AS ARRAY<ARRAY<BIGINT NOT
> NULL> NOT NULL>)
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)