HyukjinKwon opened a new pull request, #320:
URL: https://github.com/apache/spark-connect-rust/pull/320

   ### What changes were proposed in this pull request?
   
   [SPARK-61127](https://issues.apache.org/jira/browse/SPARK-61127): PySpark 
Connect's `collect` and `toLocalIterator` convert the binary values of their 
rows per the conf `spark.sql.execution.pyspark.binaryAsBytes` 
(`DataFrame._get_binary_as_bytes`):
   - `bytes` when the conf is `true`, case-insensitively, as by default
   - `bytearray` otherwise
   
   This applies to the binary values in arrays, maps and structs too, and to 
`first`, `head`, `take` and `tail`, which collect.
   
   The client now does the same. The rows of the PyO3 layer keep whether their 
binary values are `bytes`, and so do the rows of their structs.
   
   The client reads the conf only for a result with a binary value, the only 
kind of result the conf changes. So a result without one makes no extra 
request. PySpark reads the conf for every `collect`.
   
   `foreachPartition` already read the conf, as PySpark's does.
   
   ### Why are the changes needed?
   
   The client always gave `bytes`. So with the conf set to `false`, 
`df.collect()` of a binary column gave `bytes`, where PySpark 4.3.0 gives 
`bytearray`. Apache Spark's `ReadwriterParityTests.test_binary_type` failed on 
this client.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. With `spark.sql.execution.pyspark.binaryAsBytes` set to `false`, the 
binary values of collected rows are `bytearray`, as with PySpark 4.3.0. By 
default they are still `bytes`.
   
   ### How was this patch tested?
   
   - A new live test checks the types of the binary values of `collect`, 
`toLocalIterator` (with and without prefetching), `first`, `head`, `take` and 
`tail`:
     - in a column, an array, a struct and a map
     - with the conf `false`, `TRUE` and `FALSE`, then unset
   
     It passes with official PySpark 4.3.0, and fails without this change.
   - Apache Spark's parity tests of binary values, run on this client against a 
local server, pass. These are `test_binary_type` of 
`test_parity_readwriter.py`, and the `binary_type` tests of 
`test_parity_udf.py`, `test_parity_udtf.py` and 
`arrow/test_parity_arrow_python_udf.py`. Without this change, 
`test_binary_type` failed.
   - The lib tests of both crates (590 passed), the build of all tests, also 
with `wasm-udf`, the offline Python suites (2178 passed, 8 skipped), and the 
live drop-in and Arrow suites (175 passed) and live cases (10 passed) against a 
local Spark 4.3.0 server. Clippy reports no diagnostics in the changed lines.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Opus 5.5
   
   This pull request and its description were written by Isaac.
   


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