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

   ### What changes were proposed in this pull request?
   
   **The logs of the client.** With `SPARK_CONNECT_LOG_LEVEL`, or a level of 
the logger of `pyspark.sql.connect.logging`, the Python client writes the 
records of pyspark-client 4.3.0: the same logger, levels, messages, arguments 
and order, at the same points of each call. That includes:
   - **plan compression:** `Plan compression threshold: ...`, `Plan 
compression: original_size=...`, and `Plan compression not effective. Using 
original plan.`;
   - **the records of the methods:** `Executing plan`, `Schema for plan:`, 
`Explain (mode=...) for plan`, `Execute command for command`, `ExecuteAndFetch` 
and the others;
   - **requests and responses:** `ExecuteAndFetchAsIterator. Request: ...`, 
`Response received: ...`, and the batch, schema, metrics and SQL-result records;
   - **reattaches and interrupts:** the deadline and reattach records, and 
`Interrupt request received for operation=...`;
   - **records of the Python client:** `Fetching the resources` and `Creating 
the ResourceProfile`;
   - **the records that already existed:** the deadlines, retries and errors.
   
   The plans and messages are formatted by PySpark's `_proto_to_string`. 
Compression uses a single-shot zstd frame, byte-identical to 
python-zstandard's, so the logged sizes match. With the logger disabled, the 
cost is within noise.
   
   **How the records act.**
   - A handler or filter that raises at a record fails the call at that record, 
as in PySpark, and a KeyboardInterrupt there takes PySpark's interrupt path.
   - A plan is compressed once, and never after a session hook.
   - The plans of the client API are sent as given, as PySpark sends them.
   
   **The call stack.** With `SPARK_CONNECT_DEBUG_CLIENT_CALL_STACK`, the 
execute, analyze and config requests carry the call stack of the user's code as 
the last of their user context extensions, in PySpark's format.
   - Reattaches and releases copy it, a finalizer's request carries the stack 
as it runs, and a call during another call reuses that call's stack.
   - PySpark's `_retrieve_stack_frames`, `_build_call_stack_trace`, 
`_execute_plan_request_with_metadata`, `_analyze_plan_request_with_metadata`, 
`_config_request_with_metadata` and 
`_update_request_with_user_context_extensions` are on the client.
   - So PySpark's `test_client_call_stack_trace.py` passes 9 of 9 with the 
drop-in, and its entry leaves `scripts/dropin_known_failures.txt`.
   
   **The exit hook** calls the client's `_cleanup_ml_cache`, as PySpark's 
`_on_exit` does.
   
   **Docs.**
   - The KD row "The debug logs of the client" is reduced to what remains: the 
level is read at each call, the drop-in's own plan IDs and Arrow IPC bytes, and 
a few rare records.
   - A new KD row covers the call stack.
   - The row "Plan logging of a deep DataFrame" is rewritten from measurements 
under protobuf 7, protobuf 6 and the pure-Python implementation.
   - The 4.4 migration notes list the new hidden APIs of the core: the 
`client_log` module, the fallible deliveries of `retries`, and the prepared and 
as-is executions.
   
   ### Why are the changes needed?
   
   To close the KD row "The debug logs of the client" and the gap of 
`SPARK_CONNECT_DEBUG_CLIENT_CALL_STACK`: the drop-in did not log what its Rust 
transport built and read, and sent no call stack.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, the records and the extensions above, when the logger or the variable 
enables them.
   
   ### How was this patch tested?
   
   - **Golden tests** (`test_connect_logs_offline.py`), against the mock server:
     - The records were captured with official PySpark 4.3.0 under protobuf 7 
and protobuf 6.33.5, and official PySpark passes them too.
     - The cases cover collect and the other actions, plan compression, hooks, 
handlers that raise or interrupt, errors and retries, a closed client, the 
client API and the call stack.
     - Most of them fail on master.
   - **Other tests:** new tests in `test_dropin_offline.py` and the core.
   - **Live probes of both clients at DEBUG and INFO:** actions, analyses, 
commands, streaming, artifacts, ML, the client API, errors, retries, Ctrl-C and 
threads give identical records, apart from what the KD states.
   - **Call stacks:** the requests of both clients, compared through a 
recording proxy, carry identical extensions.
   - **The official tests:** `test_client_call_stack_trace.py` through 
`scripts/run_official_tests.py --dropin`.
   - **The usual checks:**
     - the core tests (release and debug), clippy, rustdoc, the stubs, the 
tooling tests and the native server's crates;
     - the offline suite under coverage;
     - the e2e with and without protobuf.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code
   
   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