You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "L. C. Hsieh (Jira)" <ji...@apache.org> on 2026/07/10 01:54:00 UTC

[jira] [Resolved] (SPARK-58050) Bulk-assemble Arrow Python UDF results

     [ https://issues.apache.org/jira/browse/SPARK-58050?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

L. C. Hsieh resolved SPARK-58050.
---------------------------------
    Resolution: Won't Do

Closing as Won't Do. Re-measurement showed the bulk output paths never engage for realistic types (the identity-children guard excludes string-bearing types due to the str() coercion contract, and for identity children the existing converter is already None), and the previously cited end-to-end gains were measurement artifacts not attributable to this change. See https://github.com/apache/spark/pull/57137#issuecomment-4931247811 for details.

> Bulk-assemble Arrow Python UDF results
> --------------------------------------
>
>                 Key: SPARK-58050
>                 URL: https://issues.apache.org/jira/browse/SPARK-58050
>             Project: Spark
>          Issue Type: Improvement
>          Components: PySpark
>    Affects Versions: 5.0.0
>            Reporter: L. C. Hsieh
>            Priority: Major
>              Labels: pull-request-available
>
> Follow-up of SPARK-58019/SPARK-58023/SPARK-58024, scoped down per review discussion to the output side only.
> The Arrow Python UDF worker converts every UDF result through a per-row Python converter (defensive list copies for arrays, dict to entry-list for maps, Row/dict to dict for structs) before {{pa.array}}. These conversions are Spark's own, independent of PyArrow's conversion performance, and use no NumPy; {{pa.array}} itself is cheap.
> Add {{LocalDataToArrowConversion._create_results_to_arrow}}: when the element/field/value converters are identity, results are assembled in bulk - arrays pass returned lists to {{pa.array}} directly, map results pass dicts directly, struct results (Rows/tuples) are transposed and assembled via {{StructArray.from_arrays}} with a null mask. Any shape/validation mismatch falls back to the per-row path, preserving error behavior.
> Microbenchmarks (400k rows, identical outputs): array<string> 7.5x, map 4.2x, struct 4.0x. End-to-end (6.4M rows): array<string> 2.39s -> 1.84s. Extending the bulk path to validation-only child converters (e.g. integers) is possible follow-up.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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