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

   ### What changes were proposed in this pull request?
   
   [SPARK-61498](https://issues.apache.org/jira/browse/SPARK-61498): follow-ups 
of a post-hoc review of SPARK-61470 (#535), checked against PySpark 4.3.0.
   
   - **The origin of an expression** (`crates/pyspark-rs/src/origin.rs`):
     - `with_origin` now returns the error of `is_debugging_enabled`, which 
reads `spark.python.sql.dataFrameDebugging.enabled` once per process.
     - The 79 functions that capture an origin (`F.col`, the Column methods, 
`groupBy`, ...) raise it, as PySpark's `_with_origin` does. Thirteen of them 
returned their value without a `PyResult`, and now return one.
     - A call site that cannot be read still leaves the expression without an 
origin, unless its error is not an `Exception`, such as a KeyboardInterrupt.
   - **`Column.__str__`** (`crates/pyspark-rs/src/column.rs`) captures no 
origin. PySpark's Column has no `__str__` of its own for `_with_origin` to 
wrap. Without this, `str(col)` would read the conf and could raise its error.
   - **The second Ctrl-C of an execution** 
(`crates/spark-connect-core/src/runtime.rs`, `watched`): once a signal has 
aborted the wait and so ended the execution, the wait cancels a running 
interrupt at once. It no longer awaits it.
   
   ### Why are the changes needed?
   
   - **A lost Ctrl-C.**
     - The origin capture dropped the errors of its conf read with 
`unwrap_or(None)`.
     - Against a server that does not answer, a Ctrl-C during the first 
`F.col("a")` of a session was lost. The call returned, built without an origin, 
and the next origin call (`F.col("b")`, `df.groupBy("id")`) waited again.
     - PySpark raises KeyboardInterrupt from `F.col` at the first Ctrl-C. In 
the review's probe, ours returned three times after three signals, and PySpark 
raised after one.
     - SPARK-61470 made that conf read interruptible, so its KeyboardInterrupt 
reached the drop.
     - The error of an unreachable server was dropped the same way, while 
PySpark raises it from `F.col`.
   - **A third Ctrl-C.**
     - During an execution, the first signal interrupts it and the second 
aborts the wait.
     - When the interrupt hung, or was retried after UNAVAILABLE, the aborted 
wait still awaited it, and only a third signal ended the call. PySpark stops at 
the second.
     - Against a mock server whose Interrupt hangs, ours raised 
KeyboardInterrupt from `collect()` after 3 signals and 5.2 s, and PySpark after 
2 signals and 3.0 s.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, as in PySpark:
   - A Ctrl-C during the first origin capture of a session raises 
KeyboardInterrupt.
   - The error of an unreachable server raises from the origin capture.
   - The second Ctrl-C ends an execution whose interrupt hangs.
   
   ### How was this patch tested?
   
   - Offline (`python/tests/test_dropin_offline.py`): new 
`test_sigint_raises_from_the_origin_capture_of_the_first_column_as_pyspark`, 
placed after 
`test_sigint_ends_a_call_to_an_unreachable_server_at_once_as_pyspark`.
     - In a subprocess against `sc://127.0.0.1:1`, a SIGINT after 1 s raises 
KeyboardInterrupt from the first `F.col`.
     - Without the change, `F.col` returns ("col returned after 1.2").
   - Rust (`runtime.rs`): new 
`test_a_second_signal_ends_the_wait_without_awaiting_a_hung_interrupt`.
     - The watch interrupts with a future that never ends, aborts at its second 
poll, and aborts again from its tenth, as a third signal would. The wait 
returns before that, and the interrupt is cancelled.
     - Without the change, it fails with "the wait needed a third signal".
   - Live, with the review's probes, against PySpark 4.3.0:
     - `F.col` against `sc://127.0.0.1:1` raises KeyboardInterrupt after one 
SIGINT (0.6 s).
     - Against a mock whose Interrupt hangs, and one whose Interrupt answers 
UNAVAILABLE, `collect()` raises KeyboardInterrupt after two SIGINTs, in 3.0 s, 
as PySpark does.
   - The SIGINT and origin tests of the offline suite (27) pass.
   - Checks:
     - the lib tests of both crates (829 passed);
     - the build of all tests, also with `wasm-udf` and `datafusion,polars`, 
without warnings;
     - `cargo fmt --all --check`, and clippy with no diagnostics on the changed 
lines;
     - `ruff check`;
     - a full trial on master before the merge.
   
   ### 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