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

   ### What changes were proposed in this pull request?
   
   PySpark 4.3.0's `SparkSession.emptyDataFrame(self, schema)` is 
`createDataFrame([], schema)` 
(`python/pyspark/sql/connect/session.py:798-799`), so the schema is required. 
The drop-in's had `signature = (schema=None)`, which its comment called a 
"permissive superset". With no schema, or with None, it returned the core's 
DataFrame of no rows and no columns.
   
   It now takes PySpark's required `schema`, and is `createDataFrame([], 
schema)` of it, with its errors:
   - `spark.emptyDataFrame()` raises `TypeError: SparkSession.emptyDataFrame() 
missing 1 required positional argument: 'schema'`;
   - `spark.emptyDataFrame(None)` raises the `PySparkValueError` of 
`CANNOT_INFER_EMPTY_SCHEMA`, before any request;
   - a `StructType` or a DDL string gives the relation of no rows of 
`createDataFrame([], schema)`, as before.
   
   `inspect.signature(spark.emptyDataFrame)` shows `(schema)`, the parameter of 
PySpark's, without its annotations, as for the other native methods. 
`scripts/e2e_wrapper.py`, which called `emptyDataFrame()`, gives it a schema. 
The Rust API's `SparkSession::empty_data_frame()` is unchanged.
   
   ### Why are the changes needed?
   
   So that `emptyDataFrame` is PySpark's. Code that relied on the drop-in's 
default schema worked on it, and raises on `pyspark-client` 4.3.0. The 
signature that `inspect` shows differed too, and nothing documented either.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, the two errors above, which are PySpark 4.3.0's. Before, both calls 
returned `DataFrame[]`.
   
   ### How was this patch tested?
   
   - `test_empty_dataframe_takes_a_schema_as_pysparks` in 
`python/tests/test_dropin_offline.py`, with the mock server, fails on master 
and passes here. It checks:
     - the parameter `schema` and that it has no default;
     - the two errors, with PySpark's message, and that they send no request;
     - that a `StructType` and a DDL string send the local relation of 
`createDataFrame([], schema)`, of no data and of the JSON of the schema.
   - `test_empty_dataframe_of_a_schema_as_pyspark` in 
`python/tests/test_dropin_e2e.py`, against a Spark 4.3.0 server: the schema and 
no rows of a `StructType` and of a DDL string, and the two errors.
   - Probes of `pyspark-client` 4.3.0 and the drop-in give the same results.
   - The Rust gates:
     - `cargo +1.100.0 fmt --all --check`;
     - `cargo +1.100.0 clippy -p apache-spark-connect -p 
apache-spark-connect-core -p pyspark-rs --all-targets -- -D warnings`;
     - `RUSTDOCFLAGS="-D warnings" cargo doc --no-deps -p apache-spark-connect 
-p apache-spark-connect-core`;
     - `cargo test -p pyspark-rs --lib` as `rust.yml` runs it: 12 passed.
   - The Python gates:
     - ruff 0.14.0 `check` and `format --check`, `test_ruff_excludes.py` and 
`scripts/audit_no_stubs.sh`;
     - `scripts/check_vendored_upstream.sh` against the `v4.3.0` tag from a 
local clone of apache/spark;
     - `scripts/tests`;
     - `gen_type_stubs.py --pyspark-src <v4.3.0>/python --check`;
     - `test_type_stubs_offline.py` with mypy 2.4.1: 7 passed;
     - the guards of SPARK-61851.
   - The offline suite of `coverage.yml`, with upb: 6235 passed and 77 skipped. 
Python coverage is 94%. The skips are those of master: 68 for "not a public 
constructor", 7 that need `SPARK_REMOTE`, and `test_type_stubs_offline.py`, 
which needs mypy and ran above.
   - `test_dropin_e2e.py` against a Spark 4.3.0 server: 311 passed.
   
   ### 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