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

   ## What is the purpose of the change
   
   `_infer_type` in `flink-python/pyflink/table/types.py` inferred a list's 
element type from `obj[0]` instead of the first non-`None` element it scans 
for. When the first element is `None`, the array element type collapsed to 
`NULL`, making schema inference order-dependent:
   
   ```
   _infer_type([1, None]) -> ArrayType(BigIntType)   # correct
   _infer_type([None, 1]) -> ArrayType(NullType)     # wrong; should be 
BigIntType
   ```
   
   The `dict` branch just above already handles this correctly (it infers from 
the found non-`None` value). `from_elements([Row(c=[None, 1])])` without an 
explicit schema infers `ARRAY<NULL>`, which then typically errors downstream.
   
   ## Brief change log
   
     - Infer the array element type from the scanned non-`None` element `v` 
rather than `obj[0]`.
   
   ## Verifying this change
   
   This change added a test and can be verified as follows:
   
     - Added `TypesTests.test_infer_array_type_with_leading_none` asserting 
`_infer_type([None, 1])` yields `ArrayType(BigIntType)`.
     - Verified against the released `apache-flink` wheel: the array element 
type is `NullType` before the fix and `BigIntType` after (the all-`None` case 
still yields `ARRAY<NULL>`).
   
   ## 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: no
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (Claude Code)
   
   Generated-by: Claude Code (Opus 4.8)
   


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