You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "Yicong-Huang (via GitHub)" <gi...@apache.org> on 2026/03/24 23:19:24 UTC

[PR] [SPARK-56123][PYTHON] Refactor SQL_GROUPED_AGG_ARROW_UDF and SQL_GROUPED_AGG_ARROW_ITER_UDF to use ArrowStreamSerializer [spark]

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

   ### What changes were proposed in this pull request?
   
   Refactor `SQL_GROUPED_AGG_ARROW_UDF` and `SQL_GROUPED_AGG_ARROW_ITER_UDF` to use `ArrowStreamSerializer` as a pure I/O layer, moving all processing logic into `read_udfs()` in `worker.py`.
   
   ### Why are the changes needed?
   
   Part of SPARK-55388. This makes the eval types self-contained in `read_udfs()`, consistent with the previously refactored `SQL_SCALAR_ARROW_UDF` and `SQL_MAP_ARROW_ITER_UDF`.
   
   Changes:
   - Delete `wrap_grouped_agg_arrow_udf()` and `wrap_grouped_agg_arrow_iter_udf()` wrappers
   - Return raw `(func, args_offsets, kwargs_offsets, return_type)` from `read_single_udf()`
   - Add self-contained processing blocks in `read_udfs()` for both eval types
   - Replace `ArrowStreamAggArrowUDFSerializer` with `ArrowStreamSerializer(write_start_stream=True, num_dfs=1)`
   - Extract `_read_arrow_stream()` in `ArrowStreamSerializer` to fix a latent infinite recursion in `_load_group_dataframes` when `num_dfs != 0`
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Existing tests: `test_arrow_udf_grouped_agg.py` (38 passed), `test_unified_udf.py::test_window_agg_arrow_udf` (passed), `test_arrow_udf_scalar.py` (54 passed), `test_pandas_grouped_map.py` (51 passed).
   
   ASV micro-benchmarks show 5-25% improvement for `SQL_GROUPED_AGG_ARROW_UDF` and 0-14% for `SQL_GROUPED_AGG_ARROW_ITER_UDF`:
   
   | Scenario | UDF | Before | After | Change |
   |---|---|---|---|---|
   | few_groups_sm | sum | 0.0179s | 0.0169s | -6% |
   | few_groups_sm | mean_multi | 0.0069s | 0.0058s | -16% |
   | many_groups_sm | sum | 0.1996s | 0.1584s | -21% |
   | many_groups_sm | mean_multi | 0.1953s | 0.1460s | -25% |
   | many_groups_lg | sum | 0.0979s | 0.0870s | -11% |
   | wide_cols | mean_multi | 0.0724s | 0.0540s | -25% |
   
   ### 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: reviews-unsubscribe@spark.apache.org

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


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


Re: [PR] [SPARK-56123][PYTHON] Refactor SQL_GROUPED_AGG_ARROW_UDF and SQL_GROUPED_AGG_ARROW_ITER_UDF [spark]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on PR #54992:
URL: https://github.com/apache/spark/pull/54992#issuecomment-4128448767

   This PR depends on #54967 (`enforce_schema`). Will rebase after that one merges.


-- 
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-unsubscribe@spark.apache.org

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


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


Re: [PR] [SPARK-56123][PYTHON] Refactor SQL_GROUPED_AGG_ARROW_UDF and SQL_GROUPED_AGG_ARROW_ITER_UDF [spark]

Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng closed pull request #54992: [SPARK-56123][PYTHON] Refactor SQL_GROUPED_AGG_ARROW_UDF and SQL_GROUPED_AGG_ARROW_ITER_UDF
URL: https://github.com/apache/spark/pull/54992


-- 
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-unsubscribe@spark.apache.org

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


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


Re: [PR] [SPARK-56123][PYTHON] Refactor SQL_GROUPED_AGG_ARROW_UDF and SQL_GROUPED_AGG_ARROW_ITER_UDF [spark]

Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on PR #54992:
URL: https://github.com/apache/spark/pull/54992#issuecomment-4139324572

   merged to master


-- 
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-unsubscribe@spark.apache.org

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


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