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

   ### What changes were proposed in this pull request?
   
   This PR consolidates pandas-to-Arrow conversion logic by introducing a 
centralized `PandasToArrowConversion` class and refactoring serializers to use 
it.
   
   **Key changes:**
   
   1. **Introduced `PandasToArrowConversion` class** in `conversion.py` with:
      - `dataframe_to_batch()`: Converts `pd.DataFrame` or `List[pd.Series]` to 
`pa.RecordBatch`
      - `series_to_array()`: Converts `pd.Series` to `pa.Array`
   
   2. **Removed duplicate conversion methods** from serializers:
      - Removed all `_create_batch` methods - replaced with 
`PandasToArrowConversion.dataframe_to_batch()`
      - Removed all `_create_array` methods - replaced with 
`PandasToArrowConversion.series_to_array()` or 
`ArrowBatchTransformer.cast_array()`
   
   ### Why are the changes needed?
   
   Previously, pandas-to-Arrow conversion logic was duplicated across multiple 
serializer classes (`ArrowStreamPandasSerializer`, 
`ArrowStreamPandasUDFSerializer`, etc.), each implementing their own 
`_create_batch` and `_create_array` methods. 
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Existing tests pass. 
   
   ### 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