manner opened a new pull request, #29343:
URL: https://github.com/apache/flink/pull/29343

   ## What is the purpose of the change
   
   `PARSE_JSON` and `TRY_PARSE_JSON` accept any `BOOLEAN` expression as the 
second argument (`allowDuplicateKeys`), not only literals. The runtime 
functions declared it as a primitive `boolean`, so a NULL value failed with a 
`NullPointerException` during unboxing:
   
   ```sql
   SELECT PARSE_JSON('{}', CAST(NULL AS BOOLEAN));
   -- java.lang.NullPointerException: Cannot invoke 
"java.lang.Boolean.booleanValue()" because "null" is null
   ```
   
   The same happens for a nullable `BOOLEAN` column that is NULL for a row. 
With this change both functions return NULL in that case. The output type 
strategies (`nullableIfArgs` / `forceNullable`) already allow a NULL result.
   
   JIRA: https://issues.apache.org/jira/browse/FLINK-40852
   
   ## Brief change log
   
   - `ParseJsonFunction` and `TryParseJsonFunction` take `@Nullable Boolean 
allowDuplicateKeys` and return NULL if it is NULL.
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
   - Added SQL cases to `JsonFunctionsITCase` for `PARSE_JSON` and 
`TRY_PARSE_JSON` with a NULL `BOOLEAN` column as `allowDuplicateKeys`, 
expecting NULL. Both failed with the NPE before the fix.
   
   There are no Table API cases for this because `parseJson(boolean)` / 
`tryParseJson(boolean)` only accept a literal.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: no
     - The serializers: no
     - The runtime per-record code paths (performance sensitive): no
     - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
     - If yes, how is the feature documented? not applicable
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [x] Yes (please specify the tool below)
   
   Generated-by: Claude Opus 5.5
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to