HyukjinKwon opened a new pull request, #649:
URL: https://github.com/apache/spark-connect-rust/pull/649
### What changes were proposed in this pull request?
A follow-up to #622 from its post-merge review. The `TypeError` of an
unexpected keyword in the readers', writers' and `builder.config`'s catch-all
read the key as UTF-8. So a str key with a lone surrogate, such as
`spark.read.json(p, **{"\ud800": 1})`, raised a `UnicodeEncodeError`, where
PySpark raises `TypeError: DataFrameReader.json() got an unexpected keyword
argument '\ud800'`. The message is now joined in Python, as CPython formats it.
`builder.config` also named itself `Builder.config()`, where PySpark says
`SparkSession.Builder.config()`.
`compatibility.md` also notes two cases where a method without `**options`
words a bad keyword as PyO3 does rather than as CPython does. A key that is not
a str gets "got an unexpected keyword argument '1'" rather than "keywords must
be strings". A method that takes no arguments says "takes no keyword arguments"
rather than "got an unexpected keyword argument 'foo'". The review chose to
note these rather than add a catch-all to about 100 methods.
### Why are the changes needed?
To raise PySpark's errors.
### Does this PR introduce _any_ user-facing change?
Yes. The two errors above now match PySpark's.
### How was this patch tested?
- `test_unexpected_keywords_are_keywords_as_pyspark` now also checks a
lone-surrogate key, in all 18 methods with the catch-all, and the corrected
`builder.config` name. The offline suite passed: 2184, 8 skipped.
- Against a Spark 4.3.0 Connect server, `builder.config` and the readers
give the same messages as the official `pyspark-client` 4.3.0, for both a
lone-surrogate key and an unknown one.
### 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]