Yicong-Huang commented on code in PR #54125:
URL: https://github.com/apache/spark/pull/54125#discussion_r2776480362


##########
python/pyspark/sql/pandas/serializers.py:
##########
@@ -829,17 +626,22 @@ def dump_stream(self, iterator, stream):
         """
         import pyarrow as pa
 
-        def create_batches():
-            for packed in iterator:
-                if len(packed) == 2 and isinstance(packed[1], pa.DataType):
-                    # single array UDF in a projection
-                    arrs = [self._create_array(packed[0], packed[1], 
self._arrow_cast)]
-                else:
-                    # multiple array UDFs in a projection
-                    arrs = [self._create_array(t[0], t[1], self._arrow_cast) 
for t in packed]
-                yield pa.RecordBatch.from_arrays(arrs, ["_%d" % i for i in 
range(len(arrs))])
+        def create_batch(
+            packed: Union[
+                Tuple["pa.Array", "pa.DataType"],
+                List[Tuple["pa.Array", "pa.DataType"]],
+            ],
+        ) -> "pa.RecordBatch":
+            # Normalize: single UDF (arr, type) -> [(arr, type)]
+            if len(packed) == 2 and isinstance(packed[1], pa.DataType):
+                packed = [packed]  # type: ignore[list-item]
+            arrs = [
+                cast_arrow_array(arr, arrow_type, safe=self._safecheck, 
allow_cast=self._arrow_cast)

Review Comment:
   good catch! I aligned the parameters now.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to