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

   ### What changes were proposed in this pull request?
   
   This fixes three differences from PySpark 4.3.0 that a post-merge review of 
#612 (SRIDs) and #614 (the bools of the catalog and the writers) found. It also 
documents two known, crate-wide differences.
   
   1. **The SRID error of a collect.** collect, head, first, take, tail, 
toPandas and toArrow of a DataFrame whose schema has an SRID that PySpark does 
not support raised the server's error: `SparkException: not support type: 
GeometryType(2154)`. PySpark raises its `IllegalArgumentException` 
[ST_INVALID_SRID_VALUE]: it converts the schema of the first response that 
carries one, before the server's later failure of the stream. Those responses 
come in the order session, schema, result_complete. The drop-in now checks the 
schema when it is received, through new `*_with_schema_checked` variants of the 
collecting calls of the core. Those variants are doc-hidden and not a stable 
API. No AnalyzePlan is added; toLocalIterator already matched.
   2. **Nested types assert a DataType.** `StructField`, `ArrayType` and 
`MapType` took a type string, such as `StructField("g", "int")`, where 
PySpark's constructors assert `isinstance(..., DataType)`. They now raise 
PySpark's `AssertionError`, with its messages: `dataType int should be an 
instance of <class 'pyspark.sql.types.DataType'>`, and the same for 
`elementType`, `keyType` and `valueType`. `StructType.add` still takes a type 
string, as PySpark's does. The `ValueError` of a bad type string now carries 
the error's message instead of a Rust `Debug` dump (`SparkError { kind: ..., 
error_class: ... }`).
   3. **The bool flags of checkpoint and unionByName.** `checkpoint(eager)`, 
`localCheckpoint(eager)` and `unionByName(allowMissingColumns)` took a strict 
bool. They are now converted as PySpark's protobuf messages convert them, as 
#614 converts the other flags:
      - 0, 1 and objects with `__index__` are taken;
      - None leaves `eager` unset (false), as PySpark's constructor of the 
command does, and is a `TypeError` for `allowMissingColumns`;
      - `"x"` and `1.5` are `TypeError`s.
   4. **Docs:** two notes in the "What drop-in means" section of 
`docs/compatibility.md`:
      - PyO3's `TypeError` for too many positional arguments counts them 
without `self`;
      - a warning that the Rust core raises is attributed to the caller's frame 
and module, so `warnings.filterwarnings(..., module="pyspark")` does not match 
it.
   
   ### Why are the changes needed?
   
   For parity with PySpark 4.3.0: the error class of an unsupported SRID, the 
constructors of the nested types, and the bool arguments that PySpark accepts.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes:
   - an unsupported SRID now raises PySpark's error from these methods;
   - the nested-type constructors reject type strings;
   - the three bool flags take the values that PySpark takes.
   
   ### How was this patch tested?
   
   - New offline tests in `python/tests/test_dropin_offline.py`, all four 
failing before the change and passing after:
     - a mock that sends a `geometry(2154)` schema and then fails the stream;
     - the asserts of the nested constructors;
     - the message of a bad type string;
     - the bool conversions of the three flags.
   - Live, against a Spark 4.3.0 Connect server, the drop-in and the reference 
client give the same results:
     - collect, toPandas, first, head, take, tail, toLocalIterator and toArrow 
of the SRID case;
     - the nested constructors with a str, None, a geography string and 5;
     - the three flags with True, False, 0, 1, 2, None, an `__index__` object, 
`"x"` and `1.5`.
   - `tests/test_dropin_offline.py` and `tests/test_ml_offline.py` (2154 
passed, 8 skipped, after rebasing on master) and `tests/test_dropin_e2e.py` 
(279 passed) pass, as do `cargo test -p apache-spark-connect --lib` (679 
passed) and the live Rust e2e suites that cover collecting. `cargo fmt 
--check`, `scripts/audit_no_stubs.sh` and `ruff check` 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