[SPARK-47233][CONNECT][SS][2/2] Client & Server logic for Client side streaming query listener #46037
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Server and client side for the client side listener.
The client should start send a
add_listener_bus_listener
RPC for the first listener ever added.The server should start a long running thread and register a new "SparkConnectListenerBusListener" upon receiving the RPC, the listener should stream back the listener events to the client using the
responseObserver
created in theexecuteHandler
of theadd_listener_bus_listener
call.On the client side, a spark client method:
execute_long_running_command
is created to continuously receive new events from the server with a long-running iterator. The client starts a new thread for handing such events. Please see the graphs below for a more detailed illustration.When either the last client side listener is removed, and the client sends "remove_listener_bus_listener" call, or the
send
method ofSparkConnectListenerBusListener
throws, the long-running server thread is stopped, as an effect, the finalResultComplete
is sent to the client, closing the client's long-running iterator.Why are the changes needed?
Development of spark connect streaming
Does this PR introduce any user-facing change?
How was this patch tested?
Added unit test. Removed old unit test that created for verifying server-side listener limitations.
Was this patch authored or co-authored using generative AI tooling?
No