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

   ### What changes were proposed in this pull request?
   
   A follow-up to #629 from its post-merge review.
   
   - **A reader's lone-surrogate format and paths.** A `str` that UTF-8 cannot 
encode, such as `"\ud800"`, can be the format of a reader, or a path or an item 
of the paths of `load`, `json`, `csv`, `orc`, `text` or `parquet`. It is now 
kept, and fails when the plan is built (an action, `df.schema`), not at the 
call. It raises PySpark's `UnicodeEncodeError` with the same message, and sends 
no request.
     - Before, `spark.read.format("\ud800").load("p")` raised an empty 
`AssertionError` at `load`, and `spark.read.parquet("\ud800")` raised at the 
call. PySpark builds both DataFrames and fails at the plan.
     - The format's error comes before a path's, in the order that PySpark's 
`DataSource` builds them.
     - The error is a new core kind, `SparkErrorKind::UnicodeEncode`. It 
carries the UTF-32LE bytes of the `str`, from which the Python client rebuilds 
the exact `UnicodeEncodeError`.
   - **An unset save mode.** A writer with no save mode now sends it 
unspecified (`0`), as PySpark's `WriteOperation` does, rather than 
`ErrorIfExists` (`3`). The server writes either as an error when the path 
exists.
   
   ### Why are the changes needed?
   
   So that these calls fail at the same step, with the same error, as on 
PySpark, and so that the writer sends the same `WriteOperation`.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes.
   - The reader calls above build their DataFrame, and raise 
`UnicodeEncodeError` when the plan is built.
   - Rust: a `DataFrameWriter` without a mode sends `SAVE_MODE_UNSPECIFIED`, 
which the server writes as before. The doc-hidden `get_save_mode` returns an 
`Option<SaveMode>`. `SparkErrorKind` has the new `UnicodeEncode` variant.
   
   ### How was this patch tested?
   
   - Probed against the official `pyspark-client` 4.3.0. The reader's 
lone-surrogate format and paths raise `UnicodeEncodeError` with the same 
message at the plan. A default writer, `mode(None)`, and `mode(None)` after 
nothing all send mode `0`.
   - Against a Spark 4.3.0 Connect server, a second default write and a second 
`mode(None)` write both fail with `PATH_ALREADY_EXISTS`, as before.
   - New offline tests in `test_dropin_offline.py`: 
`test_reader_strings_that_utf8_cannot_encode_fail_the_plan_as_pyspark` and 
`test_writer_without_a_mode_sends_it_unspecified_as_pyspark`. The file passed 
2224 tests, with 8 skipped (`TZ=UTC`).
   - Rust: the core unit tests passed 220, the `readwriter` unit tests 16, and 
`readwriter_golden` 11. Clippy and fmt are clean.
   - Two sibling cases are not changed here:
     - `spark.readStream.format("\ud800").load()` still raises `AssertionError` 
at `load`, where PySpark defers it to `isStreaming`.
     - `spark.read.table("\ud800")` still raises at the call, where PySpark 
defers it to the plan.
   
   ### 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