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

   ## What is the purpose of the change
   
   In thread mode, a Python UDF in the Table API can fail with a 
`NullPointerException` when a null input or result reaches a converter that 
dereferences it. The Table runtime's `PythonTypeUtils.DataConverter` passes 
nulls straight into `toInternalImpl` and `toExternalImpl`. This happens for 
null `TINYINT`, `SMALLINT`, `INT`, `FLOAT`, `TIME`, `MAP` and `ROW` fields, and 
for null `ROW` elements in an `ARRAY` or values in a `MAP`. A UDF returning 
`None` for a `TINYINT`, `INT` or `ROW` result hits it too. Process mode handles 
all of these.
   
   ## Brief change log
   
     - `DataConverter` returns null for a null value in both directions, the 
same way `DataFormatConverters.DataFormatConverter.toInternal` and `toExternal` 
do.
     - The nested `ROW`, `ARRAY` and `MAP` converters go through the same null 
check for their fields, elements, keys and values.
   
   ## Verifying this change
   
   This change added tests and can be verified as follows:
   
     - Added `test_null_values` to `UserDefinedFunctionTests`, which runs in 
process and thread mode. It round-trips the null inputs through identity UDFs 
and checks UDFs that return `None` for `TINYINT`, `INT` and `ROW` from a 
non-null input. Without the fix, the thread-mode runs failed and the 
process-mode runs passed.
     - Added `test_map_with_null_nested_row` to 
`EmbeddedThreadRowBasedOperationITTests`, based on the reproducer in the JIRA 
issue.
     - `test_udf.py` and `test_row_based_operation.py`: 84 passed, 1 skipped. 
The Table runtime's `PythonTypeUtilsTest` passes.
   
   ## 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): yes, adds one 
null check per conversion in thread mode, including nested values
     - 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 Code 2.1.321 (Claude Opus 5.5)
   


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