Repository navigation
feat(python): Add Python gRPC client with BallistaPythonSessionContext - #2754
Merged
Merged
Conversation
BallistaPythonSessionContext`
Contributor
Author
|
using python grpc client to communicate with ballista instead of rust client, this might give us opportunity to configure client any way we want. any opinions @andygrove (btw, i will review code later) |
BallistaPythonSessionContext`BallistaPythonSessionContext
BallistaPythonSessionContextBallistaPythonSessionContext
milenkovicm
force-pushed
the
feat_python_grpc
branch
from
November 3, 2026 16:56
236abca to
6b187a0
Compare
andygrove
reviewed
Nov 3, 2026
andygrove
left a comment
Member
There was a problem hiding this comment.
Thanks for this, it's a nice addition and the extraction of execute_query_params looks clean. I left two inline notes on things that would be easier to settle before this merges.
milenkovicm
force-pushed
the
feat_python_grpc
branch
from
November 3, 2026 19:41
6b187a0 to
ed9ec1b
Compare
milenkovicm
force-pushed
the
feat_python_grpc
branch
from
November 3, 2026 20:10
ed9ec1b to
b7bee93
Compare
milenkovicm
marked this pull request as ready for review
November 3, 2026 20:10
milenkovicm
force-pushed
the
feat_python_grpc
branch
from
November 3, 2026 20:22
b7bee93 to
72f5b1b
Compare
Contributor
Author
|
should be merged after #2748 |
milenkovicm
force-pushed
the
feat_python_grpc
branch
from
November 4, 2026 08:51
72f5b1b to
422d98a
Compare
andygrove
reviewed
Nov 5, 2026
andygrove
left a comment
Member
There was a problem hiding this comment.
Thanks Marko, this is a nice addition. One question on settings, plus a couple of small things inline.
Also, the description still says grpcio/protobuf/pyarrow are runtime deps, but they're in the python-client extra now.
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Nov 5, 2026
the Python gRPC stubs every time it updates the vendored protos
the session actually reaches the scheduler
milenkovicm
force-pushed
the
feat_python_grpc
branch
from
November 5, 2026 22:02
d051f19 to
416fbe3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Which issue does this PR close?
Closes #.
Rationale for this change
Today, all communication between the Python client and a Ballista cluster happens in Rust, inside
DistributedQueryExec. That covers submitting the job, tracking its status, fetching results over Arrow Flight, and cancelling the job. Python users can't change how the cluster is reached (authentication headers, TLS, custom channels, result handling) without changing Rust code.This PR adds a second client written in Python. It sits beside the existing native client; nothing is replaced. Plans are still built and encoded in Rust, because that needs Ballista's logical extension codec. A thin Rust exec node, created during planning, passes the encoded query to a Python
BallistaClient, which does all gRPC and Flight work. Users pick a client by choosing a session context, which also makes it easy to compare the two.What changes are included in this PR?
Python client (
python/python/ballista/client.py)BallistaClientsubmits jobs to the scheduler, tracks them by polling (pull) or by theExecuteQueryPushstatus stream (push), and fetches results withpyarrow.flightdo_get. The ticket is the sameAction::FetchPartitionprotobuf the Rust client sends.create_channel,call_metadataandcreate_flight_client.ballista.*settings, which override Ballista defaults.ensure_alignment; older versions copy each batch.Rust node and planner (
python/src/python_query_exec.rs)PythonDistributedQueryExecencodes the query, callsclient.execute(params, schema), and streams results through the Arrow C stream interface on the blocking pool. Dropping the stream closes the job.PythonDistributedExplainAnalyzeExecfetches job metrics throughclient.job_metrics(job_id).PythonClientQueryPlanneruses the same planning rules asBallistaQueryPlanner.BallistaPythonClientExtensioninstalls the planner and codecs throughSessionContext.with_extensions.Codec (
python/src/codec.rs)DistributedQueryExecNode/DistributedExplainAnalyzeExecNodeinto the Python-backed execs. A codec without a client, such as the one used by schedulers and executors started from Python, behaves as before. No.protochanges.ballista-core
execute_query_paramsis extracted fromDistributedQueryExec::execute, so both clients build the sameExecuteQueryParams. Behaviour is unchanged.format_metrics_as_record_batchis now public.Python package
BallistaPythonSessionContext.BallistaSessionContextis unchanged.BallistaClient,BallistaJob,BallistaJobError.ballista/core/protoare committed underballista/proto/. They are regenerated withdev/generate_proto.sh.Build and CI
grpcio>=1.85.1,protobuf>=7.35.1,<8.pyarrowmoves from a test dependency to a runtime one. The minimum versions match what the generated code checks at import time.grpcio-toolsis pinned in the dev group so regenerated stubs are identical, dependencies are hidden behindpython-clientdependency optionTests
ctxfixture intest_context.pynow runs every context test against both clients.test_client.pycovers:push-stagedscheduler, in both pull and push mode, with the same results as the native client. The in-process test cluster runspull-staged, so pipelined mode is not covered by automated tests.Not yet done in the Python client:
ballista.client.grpc_connect_timeout_secondsand the HTTP/2 window size options are not mapped to gRPC options.job_execution_time_ms,job_scheduling_in_ms,total_query_time_ms) are not reported.Are there any user-facing changes?
Yes, all additive:
BallistaPythonSessionContextandBallistaClientin the Python package. ExistingBallistaSessionContextusers see no change.grpcio,protobufandpyarrow.ballista-core:execution_plans::execute_query_paramsandexecution_plans::format_metrics_as_record_batch.There are no breaking API changes and no wire or serialization format changes.
🤖 Generated with Claude Code