EnricoMi opened a new pull request, #38624:
URL: https://github.com/apache/spark/pull/38624

   ### What changes were proposed in this pull request?
   Add `applyInArrow` method to PySpark `groupBy` and `groupBy.cogroup` to 
allow for user functions that work on Arrow. Similar to existing `mapInArrow`, 
this allow
   
   ### Why are the changes needed?
   PySpark allows to transform a `DataFrame` via Pandas and Arrow API:
   ```
   df.mapInArrow(map_arrow, schema="...")
   df.mapInPandas(map_pandas, schema="...")
   ```
   
   For `df.groupBy(...)` and `df.groupBy(...).cogroup(...)`, there is only a 
Pandas interface, no Arrow interface:
   ```
   df.groupBy("id").applyInPandas(apply_pandas, schema="...")
   ```
   
   Providing a pure Arrow interface allows user code to use **any** Arrow-based 
data framework, not only Pandas, e.g. Polars:
   ```
   def apply_polars(df: polars.DataFrame) -> polars.DataFrame:
     return df
   
   def apply_arrow(table: pyarrow.Table) -> pyarrow.Table:
     df = polars.from_arrow(table)
     return apply_polars(df).to_arrow()
   
   df.groupBy("id").applyInArrow(apply_arrow, schema="...")
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   This adds method `applyInPandas` to PySpark `groupBy` and `groupBy.cogroup`.
   
   ### How was this patch tested?
   Tested with unit tests.


-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to