[
https://issues.apache.org/jira/browse/FLINK-40852?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sergey Nuyanzin resolved FLINK-40852.
-------------------------------------
Fix Version/s: 2.4.0
Resolution: Fixed
> PARSE_JSON fails with NullPointerException when allowDuplicateKeys is NULL
> --------------------------------------------------------------------------
>
> Key: FLINK-40852
> URL: https://issues.apache.org/jira/browse/FLINK-40852
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / Runtime
> Reporter: Moritz Manner
> Priority: Minor
> Labels: pull-request-available
> Fix For: 2.4.0
>
>
> {{PARSE_JSON(json, allowDuplicateKeys)}} and {{TRY_PARSE_JSON(json,
> allowDuplicateKeys)}} accept any {{BOOLEAN}} expression as the second
> argument, not only literals. If that argument is NULL at runtime, the query
> fails instead of returning NULL.
> To reproduce:
> {code:java}
> SELECT PARSE_JSON('{}', CAST(NULL AS BOOLEAN));{code}
>
> {code:java}
> Caused by: java.lang.NullPointerException: Cannot invoke
> "java.lang.Boolean.booleanValue()" because "null" is null at
> StreamExecCalc$9.processElement(Unknown Source){code}
>
> {{TRY_PARSE_JSON}} fails the same way. A nullable {{BOOLEAN}} column that is
> NULL for a row, e.g. {{{}PARSE_JSON(f0, f1){}}}, triggers it too.
> The cause is that {{ParseJsonFunction}} and {{TryParseJsonFunction}} declare
> {{eval(StringData, boolean)}} with a primitive {{{}boolean{}}}, so the
> generated code unboxes the NULL value. The output type strategies
> ({{{}nullableIfArgs{}}} for PARSE_JSON, {{forceNullable}} for TRY_PARSE_JSON)
> already allow a NULL result.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)