HyukjinKwon opened a new pull request, #622:
URL: https://github.com/apache/spark-connect-rust/pull/622
### What changes were proposed in this pull request?
A follow-up to #604 for the methods whose PyO3 signatures have no
`**kwargs`. With a keyword key that is not a str, as in `spark.read.json(p,
**{1: "1"})`, these now raise PySpark's `TypeError: keywords must be strings`,
before anything is sent. The methods:
- `DataFrameReader.json`, `csv`, `orc`, `text` and `xml`;
- `DataStreamReader.json`, `parquet`, `csv`, `text`, `orc` and `xml`;
- `DataFrameWriter.parquet`, `json`, `csv`, `orc`, `text` and `xml`;
- `SparkSession.builder.config`.
Each takes a catch-all `**unexpected`, which its pinned `text_signature`
does not show, and checks it first with a new helper next to
`check_keyword_keys` in `options.rs`. An unexpected str key, as `foo=1`, raises
the same `got an unexpected keyword argument 'foo'` as before.
### Why are the changes needed?
PyO3 rejected the key itself, with `<Class>.<method>() got an unexpected
keyword argument '1'`, before #604's check could run. PySpark's methods are
Python functions, for which CPython raises `keywords must be strings`. A
post-merge review of #604 found the difference.
### Does this PR introduce _any_ user-facing change?
Yes. The `TypeError` of a non-str keyword key now matches PySpark 4.3.0. The
visible signatures do not change.
### How was this patch tested?
- A new offline test covers all 18 methods with `{1: "1"}` and `{"foo": 1}`.
It asserts both exact messages, and that no request is sent, through a session
without a server. Another test checks that known keywords still bind.
- `test_dropin_offline.py`: 1992 passed, 8 skipped.
- The reader, writer and session subset of `test_dropin_e2e.py` against a
Spark 4.3.0 Connect server: 38 passed.
- `__text_signature__` and `inspect.signature` are identical before and
after, for all 18 methods.
- Against the official `pyspark-client` 4.3.0, every method raises the same
two messages, except one. `builder.config` with an unknown str key says
`Builder.config()` where PySpark says `SparkSession.Builder.config()`, and that
wording predates this change.
### 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]