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

   ### What changes were proposed in this pull request?
   
   PySpark's `DataFrame.persist(storageLevel)` defaults `storageLevel` to 
`MEMORY_AND_DISK_DESER`, and when it is given `None` explicitly, its client 
sends no storage level (`core.py`: `if kwargs.get("storage_level", None) is not 
None`). The server then caches at its `spark.sql.defaultCacheStorageLevel`. 
This PR does the same in the Python client:
   
   - The core's `DataFrame::persist` takes `impl Into<Option<StorageLevel>>`. 
Passing a `StorageLevel` works as before. `None` sends no storage level. 
`cache` is unchanged.
   - The drop-in's `persist` tells an omitted `storageLevel` apart from a given 
`None`, using a `PersistLevel` argument, as the `StorageLevel` constructor's 
`Replication` already does.
   - `docs/compatibility.md`'s "Rust migration for the 4.3 line" describes the 
new `persist` signature.
   
   ### Why are the changes needed?
   
   For parity with PySpark 4.3.0. The client sent `MEMORY_AND_DISK_DESER` for 
`persist(None)` too, so the server's default storage level was ignored:
   
   ```python
   spark.conf.set("spark.sql.defaultCacheStorageLevel", "DISK_ONLY")
   df = spark.range(5)
   df.persist(None)
   df.storageLevel
   ```
   
   - PySpark 4.3.0: `StorageLevel(True, False, False, False, 1)` (DISK_ONLY, 
the server default)
   - Before: `StorageLevel(True, True, False, True, 1)` (MEMORY_AND_DISK_DESER)
   - After: `StorageLevel(True, False, False, False, 1)`
   
   `df.persist()` with no argument gives `MEMORY_AND_DISK_DESER` on both, as 
before.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. `persist(None)` now caches at the server's default storage level, as in 
PySpark. In the Rust API, `DataFrame::persist` also accepts `None`.
   
   ### How was this patch tested?
   
   - Offline: `test_persist_of_none_sends_no_storage_level_as_pyspark` checks 
what omitted, `None` and `storageLevel=None`, and an explicit level send. It 
fails without the fix, which sent `MEMORY_AND_DISK_DESER` for `None`.
   - Core: `persist_of_no_storage_level_sends_none_as_pyspark`.
   - e2e: 
`test_persist_of_none_caches_at_the_default_storage_level_of_the_server_as_pyspark`,
 against Spark 4.3.0 with `spark.sql.defaultCacheStorageLevel=DISK_ONLY`.
   - A probe gives the same output on PySpark 4.3.0 and the client: omitted, 
`None`, `storageLevel=None` and `MEMORY_ONLY`, plus the `AssertionError` of 
`0`, `""`, `False` and a tuple.
   - With `TZ=UTC` under the default (upb) protobuf backend:
     - CI's offline set (`test_dropin_offline.py`, `test_arrow_handoff.py`, 
`test_ml_offline.py`): 3273 passed.
     - The Rust lib tests and the `--no-run` builds with and without `wasm-udf`.
     - `cargo fmt`, `scripts/audit_no_stubs.sh`, and ruff 0.14.0 `check` and 
`format --check`.
   
   ### 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