[
https://issues.apache.org/jira/browse/FLINK-40852?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18124438#comment-18124438
]
Sergey Nuyanzin commented on FLINK-40852:
-----------------------------------------
Merged as
[2c768cde3bacf9e09b9791fdd91e4f3731614c36|https://github.com/apache/flink/commit/2c768cde3bacf9e09b9791fdd91e4f3731614c36]
> 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
>
> {{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)