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

   ### What changes were proposed in this pull request?
   
   [SPARK-61292](https://issues.apache.org/jira/browse/SPARK-61292): 
`DataFrame.isLocal` of the Python client asks the server, as PySpark's does, 
instead of answering from the client's own plan.
   
   - `spark-connect` gets `DataFrame::is_local_on_server`, which sends an 
`AnalyzePlan` `IsLocal` request of the DataFrame's plan and returns the 
server's answer. The answer is cached per DataFrame, as the schema is: exact 
clones share it, a derived DataFrame asks the server for its own plan, and a 
failed request is not cached. The existing client-side `DataFrame::is_local` is 
unchanged.
   - `pyspark-rs` binds `isLocal` to `is_local_on_server`, detaching from the 
GIL while the request runs, as `isStreaming` does.
   - Offline tests in `python/tests/test_dropin_offline.py` use the mock 
server, which now answers `IsLocal` from the root relation of the plan (or from 
a value a test sets). They cover one request per DataFrame, the server's answer 
being returned, and a failure not being cached. The offline checks of 
`createDataFrame` local-ness now go through that mock server, since the answer 
is no longer computed locally.
   - Live tests: `python/tests/test_dropin_e2e.py` checks `isLocal` for 
`VALUES`, `SHOW DATABASES`, `SELECT 1`, `createDataFrame` and `range`, and 
`crates/spark-connect/tests/e2e_new_methods.rs` checks the server's answer in 
Rust.
   
   ### Why are the changes needed?
   
   PySpark's `DataFrame.isLocal` sends an `AnalyzePlan` `IsLocal` request, and 
the server answers from the plan it analyzes. The drop-in answered from the 
plan on the client, so only a local relation built by the client, or a command 
result, was local. The two differ where the server resolves another plan into a 
local relation: `spark.sql("VALUES (1)").isLocal()` was `False` and PySpark 
returns `True`.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, in the Python client. `DataFrame.isLocal()` now returns the server's 
answer, as PySpark does, and sends one request per DataFrame, as PySpark's 
cached call does. For example, `spark.sql("VALUES (1)").isLocal()` is now 
`True`, where it was `False`. The Rust API gains 
`DataFrame::is_local_on_server`; `DataFrame::is_local` is unchanged.
   
   ### How was this patch tested?
   
   - `cargo test -p apache-spark-connect --release --lib`: 528 passed.
   - `cargo test -p apache-spark-connect --release --no-run` and with 
`--features wasm-udf`: compile.
   - `cargo fmt --all --check`: passes.
   - Offline Python with the mock server: `tests/test_dropin_offline.py` 1644 
passed, `tests/test_ml_offline.py` 97 passed, `tests/test_arrow_handoff.py` 
1189 passed. The new tests are 
`test_is_local_asks_the_server_once_per_dataframe`, 
`test_is_local_returns_the_servers_answer` and 
`test_is_local_failure_is_not_cached`. The `createDataFrame` local-ness tests 
now ask the mock server, and the arrow handoff mock answers `IsLocal`.
   - With the extension built from master, the three new offline tests fail; 
with this change they pass.
   - Live Python against a Spark 4.3.0 Connect server: the drop-in, Arrow and 
ML suites pass (241 passed, 1 skipped), including the new 
`test_is_local_is_the_servers_answer_as_pyspark` (five cases: `VALUES (1)` and 
`SHOW DATABASES` are local, `SELECT 1` and `range(1)` are not, 
`createDataFrame` is). The five cases give the same answers with PySpark 4.3.0 
on the same server.
   - Clippy reports no diagnostics on the changed lines.
   - Live Rust 
(`crates/spark-connect/tests/e2e_new_methods.rs::is_local_on_server_is_the_servers_answer`)
 passes against the same server.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Opus 5.5 and Claude Haiku 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