Yicong-Huang opened a new pull request, #53951:
URL: https://github.com/apache/spark/pull/53951

   ### What changes were proposed in this pull request?
   
   This PR refactors `GroupArrowUDFSerializer.load_stream` to reuse 
`ArrowBatchTransformer.flatten_struct` instead of an inline `process_group` 
function that duplicates the same logic.
   
   Before:
   ```python
   def process_group(batches):
       for batch in batches:
           struct = batch.column(0)
           yield pa.RecordBatch.from_arrays(struct.flatten(), 
schema=pa.schema(struct.type))
   
   batch_iter = process_group(ArrowStreamSerializer.load_stream(self, stream))
   ```
   
   After:
   ```python
   batch_iter = map(
       ArrowBatchTransformer.flatten_struct,
       ArrowStreamSerializer.load_stream(self, stream),
   )
   ```
   
   ### Why are the changes needed?
   
   This is a follow-up to 
[SPARK-55162](https://issues.apache.org/jira/browse/SPARK-55162) and part of 
[SPARK-55159](https://issues.apache.org/jira/browse/SPARK-55159) Phase 1: 
eliminating duplicated transformation logic across serializers.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Existing tests in `test_arrow_grouped_map.py`.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   No.
   


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