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

   ### What changes were proposed in this pull request?
   
   The DataSource reads of the client now send what PySpark's readers send. A 
review of the readwriter golden test 
(`crates/spark-connect/tests/readwriter_golden.rs` claimed protobuf parity with 
PySpark, but read no golden) found two differences:
   
   1. **The schema of a read with no schema.** PySpark's `DataFrameReader` and 
`DataStreamReader` start with `_schema = ""` (`readwriter.py:80`, 
`streaming/readwriter.py:58`), and their `DataSource` sends it as the read's 
schema (`plan.py:368`). The core omitted the field. The server reads both forms 
as no schema (`hasSchema && nonEmpty` in `SparkConnectPlanner`). Every 
DataSource read of the batch and stream readers now sends `schema: ""` when 
none is set: `load_paths`, the predicates read, and the stream reader's loads 
and formats.
   2. **`text()`'s `wholetext`.** PySpark's `text(paths, wholetext=False, ...)` 
always sets the option, also over an earlier `option("wholetext", ...)`. The 
batch reader writes it as `"false"` (`to_str`), and the stream reader's 
`option` as `str(False)`, `"False"`. The Rust API's `text()` now does the same. 
The binding's stream `text` loads with the options of its own arguments, so a 
`wholetext=True` there is kept.
   
   The golden becomes real:
   - `scripts/capture_readwriter_golden.py` captures 
`tests/golden/readwriter.jsonl` on official PySpark 4.3.0: 10 reads, 
deterministic. The script is fixed for protobuf 7, which has no 
`FieldDescriptor.label`.
   - `readwriter_golden.rs`'s new `reads_match_official_pyspark` compares the 
Rust API's reads with it.
   - `streaming_golden.rs` gets `stream_reads_send_pysparks_schema_and_options`.
   
   ### Why are the changes needed?
   
   So that the requests of the reads are PySpark's, which the drop-in promises, 
and so that the readwriter golden test checks what it claims. Without the 
option, a Rust `text()` after `option("wholetext", "true")` read whole files, 
where PySpark's `text()` reads lines.
   
   ### Does this PR introduce _any_ user-facing change?
   
   - The requests of reads gain `schema: ""`, which the server treats as before.
   - The Rust API's `DataFrameReader::text` and `DataStreamReader::text` read 
lines even after `option("wholetext", "true")`, as PySpark's `text()` does. 
`wholetext` is a parameter of PySpark's `text`, not something to set before it.
   
   ### How was this patch tested?
   
   - A probe of 12 reads (batch and stream: json, text with and without 
`wholetext`, an option before `text`, jdbc predicates, a load with no format, 
rate, a schema) gives the same relations on official PySpark 4.3.0 and on the 
drop-in with this PR. Master differs in 11 of them.
   - `cargo test -p apache-spark-connect --release --lib` (743 passed), and 
`--test readwriter_golden --test streaming_golden --test plans_golden`. The new 
golden test fails on master's reader.
   - `test_dropin_offline.py` (2268 passed).
   - `cargo fmt --all --check`, `cargo +1.100.0 clippy -p apache-spark-connect 
-p pyspark-rs --all-targets -- -D warnings`, and ruff 0.14.0.
   
   ### 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