polsinello commented on code in PR #27927:
URL: https://github.com/apache/flink/pull/27927#discussion_r3125033440


##########
flink-python/pyflink/fn_execution/embedded/converters.py:
##########
@@ -162,12 +199,291 @@ def __init__(self, field_converter: DataConverter):
         super(ArrayDataConverter, self).__init__(field_converter)
 
     def to_internal(self, value) -> IN:
-        return tuple(super(ArrayDataConverter, self).to_internal(value))
+        if value is None:
+            return None
+
+        return list(super(ArrayDataConverter, self).to_internal(value))

Review Comment:
   The asymmetry is driven by pemja's Python↔Java type-coercion table:
   
   - `to_internal` (Java → Python UDF arg) returns `list` to match 
process-mode's Beam-based path — UDFs see mutable sequences in both modes, so 
code like `arr.append(x) / arr[i] = v` doesn't
   break only in thread mode. Before this change, thread mode returned a 
`tuple`, which created a subtle UDF-visible divergence between modes.
   - `to_external` (Python return → Java) stays `tuple` because pemja coerces 
`tuple` → `Object[]` (what the downstream Java ArrayDataConverter expects), 
whereas `list` → `ArrayList`, which would
   break `ArrayDataConverter.toExternalImpl`'s typed-array element loop.
   
   I've added a class-level docstring on `ArrayDataConverter` documenting the 
asymmetry.



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