You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "haoyangeng-db (via GitHub)" <gi...@apache.org> on 2026/08/31 20:15:23 UTC
[PR] ®[WIP][CONNECT][PYTHON] Handle metadata in command response streams [spark]
haoyangeng-db opened a new pull request, #58435:
URL: https://github.com/apache/spark/pull/58435
### What changes were proposed in this pull request?
This PR makes `SparkConnectClient.execute_command_as_iterator` yield every decoded response item instead of requiring every item to be a dictionary. Streaming-query listener and pipeline consumers ignore `PlanMetrics` and `ObservedMetrics` while continuing to reject unrelated malformed responses.
It also creates Python Data Source profiler accumulators only when performance or memory profiling is enabled.
### Why are the changes needed?
Python Data Source workers currently register profiler accumulators even when profiling is disabled. Their empty accumulator updates can arrive alongside command results as observed metrics. The Spark Connect command iterator treats those valid non-dictionary responses as unknown and terminates long-lived command streams, including streaming listeners.
The low-level iterator already decodes several legitimate response types, so it should preserve them and let each command-specific consumer decide which types it accepts.
### Does this PR introduce _any_ user-facing change?
Yes. Spark Connect command streams no longer fail when valid execution metrics accompany command results. Python Data Source workers also stop sending empty profiler updates when profiling is disabled. Unexpected response shapes still raise an error.
### How was this patch tested?
Added focused tests covering:
- command results followed by plan and observed metrics;
- protobuf extension responses;
- streaming-listener metadata before and after registration;
- malformed listener and pipeline responses;
- disabled, unsupported, performance, and memory profiler modes;
- preservation of ordinary accumulator updates.
All 7 focused tests and all 44 tests in the mocked Spark Connect client suite passed. Ruff check/format and `git diff --check` passed.
A full SBT build could not resolve external dependencies in this environment because DNS was unavailable.
### Was this patch authored or co-authored using generative AI tooling?
Co-authored with Codex
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-59135][CONNECT][PYTHON] Handle metadata in command response streams [spark]
Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng closed pull request #58435: [SPARK-59135][CONNECT][PYTHON] Handle metadata in command response streams
URL: https://github.com/apache/spark/pull/58435
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-59135][CONNECT][PYTHON] Handle metadata in command response streams [spark]
Posted by "haoyangeng-db (via GitHub)" <gi...@apache.org>.
haoyangeng-db commented on code in PR #58435:
URL: https://github.com/apache/spark/pull/58435#discussion_r3981745978
##########
python/pyspark/sql/tests/connect/streaming/test_parity_listener.py:
##########
@@ -84,6 +98,50 @@ def onQueryTerminated(self, event):
self.terminated.append(event)
+@unittest.skipIf(not should_test_connect, connect_requirement_message)
+class StreamingQueryListenerBusResponseTests(unittest.TestCase):
Review Comment:
Done.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-59135][CONNECT][PYTHON] Handle metadata in command response streams [spark]
Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on code in PR #58435:
URL: https://github.com/apache/spark/pull/58435#discussion_r3950148685
##########
python/pyspark/sql/tests/connect/streaming/test_parity_listener.py:
##########
@@ -84,6 +98,50 @@ def onQueryTerminated(self, event):
self.terminated.append(event)
+@unittest.skipIf(not should_test_connect, connect_requirement_message)
+class StreamingQueryListenerBusResponseTests(unittest.TestCase):
Review Comment:
These are Connect-only unit tests: they instantiate `StreamingQueryListenerBus` directly and have no classic counterpart, while this module's existing suite is the Connect implementation of `StreamingListenerTestsMixin`. Please move this class to a Connect-specific `streaming/test_listener.py` so `test_parity_listener.py` remains limited to shared classic/Connect parity coverage.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-59135][CONNECT][PYTHON] Handle metadata in command response streams [spark]
Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on PR #58435:
URL: https://github.com/apache/spark/pull/58435#issuecomment-5635233051
**Merge Summary:**
- merged into master https://github.com/apache/spark/commit/29a4be87d653da8efd7e0242ce3ccf1358b938dd
- merged into branch-4.x https://github.com/apache/spark/commit/66c1999da7996384d59787c2fc438152b33d2795
*Posted by `merge_spark_pr.py`*
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org