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

   ### What changes were proposed in this pull request?
   
   A follow-up of the post-merge review of #571 and #568, in the Python client:
   
   - The `**options` and `**kwargs` methods raise PySpark's `TypeError: 
keywords must be strings` for a key that is not a str. They raise it before 
anything is done or set, and send nothing:
     - readers, stream readers, writers, stream writers and writer V2: 
`options`, `load`, `parquet`, `save`, `saveAsTable`, `start`, `toTable`, 
`_set_opts`;
     - `catalog.createTable` and `createExternalTable`;
     - `show` and `_show_string`, `sort`, `orderBy`, `sortWithinPartitions`, 
`_to_pandas`;
     - `Column.alias` and `name`.
   
     PySpark's methods are Python functions, so CPython refuses such a key 
before the call runs. The check is shared with #568's jdbc properties.
   - `DataFrameReader.jdbc` asserts that `predicates` is a list of str, after 
the reader has its url and dbtable, as PySpark's `DataSource` plan does. A 
tuple, a str or an item that is not a str raises a bare `AssertionError`.
   - `show`'s `n` and `truncate` are converted as protobuf's int32 fields 
(`ShowString.num_rows` and `truncate`), as #571 did for `limit`, `offset` and 
the others.
   
   ### Why are the changes needed?
   
   For parity with PySpark 4.3.0 (under protobuf's default upb backend). Each 
pair below is ours before this change, then PySpark:
   
   - `spark.read.format("json").options(**{b"multiLine": True}).load(p)`: the 
option was set as the name `b'multiLine'` and silently ignored, so a multi-line 
JSON file read as corrupt records / `TypeError: keywords must be strings`.
   - `df.show(**{1: "1"})`: `TypeError: 'int' object is not an instance of 
'str'` / `TypeError: keywords must be strings`.
   - `F.col("id").alias("x", **{1: "1"})`: `AssertionError: Unexpected kwargs 
where passed` / `TypeError: keywords must be strings`.
   - `df.sort("id", **{1: True})`: accepted / `TypeError`.
   - `spark.read.jdbc(url, "t", predicates=("a=1",))`: accepted / 
`AssertionError`.
   - `predicates=[1]`: `TypeError` / `AssertionError`.
   - `df._show_string(2**31)`: `OverflowError` / `ValueError: Value out of 
range: 2147483648`.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. A non-str option key raises PySpark's `TypeError` instead of being set 
or ignored. The jdbc predicates and an out-of-range `show` count raise 
PySpark's errors.
   
   ### How was this patch tested?
   
   - New offline tests in `python/tests/test_dropin_offline.py`, each checked 
to fail without the change and to send nothing for a refused call:
     - `test_option_keys_that_are_not_str_are_keywords_as_pyspark`: int and 
bytes keys at 22 call sites;
     - `test_jdbc_predicates_are_checked_as_pyspark`;
     - `test_show_counts_are_proto_int32_as_pyspark`.
   - A probe of 24 entry points matches the reference under upb.
   - With `TZ=UTC`: CI's offline set, 3282 passed; `test_dropin_e2e.py`, 276 
passed; `test_arrow_e2e.py`, 11 passed.
   - The Rust lib tests, the `--no-run` builds with and without `wasm-udf`, 
`cargo fmt`, the stub audit and ruff pass.
   
   ### 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