feat: add comet-scheduler and comet-executor for Comet Native Executors #7299
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #7299"
general
weight: 0.35
sunchao
Which issue does this PR close?
Part of #7288.
Rationale for this change
#7288 designs Comet Native Executors: an optional deployment mode where a Spark driver plans each query and a cluster of native processes built on Apache DataFusion Ballista runs it, with no JVM in the data plane. The draft prototype, #7289, runs TPC-H q1 that way end to end.
This PR lands the native side of that prototype: everything needed to run a Comet stage graph on a cluster, without connecting it to Spark yet. Users see no change, and the main Comet build gains no dependency. The Spark driver side follows in #7289, which will be rebased onto main once this merges.
What changes are included in this PR?
One commit per part; it reviews best commit by commit.
1. Wire protocol.
native_executors.protodefinesQueryRequest: a stage graph of Comet native blocks connected by the exchanges between them. Each stage carries its Spark output schema and, for stages that read files, each partition's plan.Fragmentcarries a stage from the scheduler to its executors. The proto crate exports a fingerprint of the.protofiles, so a cluster can refuse a query from another Comet build.2. Native blocks outside Spark.
CometFragmentExecruns a stage's block for each of its partitions.- Inputs: a new planner seam,
PhysicalPlanner::with_native_inputs, feeds the block's input leaves from other DataFusion plans instead of from the JVM. An expression that calls into the JVM, such as a scalar subquery or a JVM UDF, fails to plan.PhysicalPlanner::without_dataplans a block the same way without its data, to check it: its input leaves are empty, and its file scans build no object store.- Output types: each partition's output is cast to the stage's declared Spark types before it leaves the stage, as Comet's shuffle writer does in a Spark task, because where a hash exchange sends a row depends on its keys' types as well as their values. Each batch then carries the stage's schema, with every column nullable: the cast keeps a column nullable wherever the block's output is, even where Spark knows it has no nulls.
- Memory and spills: the block runs in a Comet session over the host's memory pool and disk manager.
- Partition descriptor: an extra child, an in-memory source with one row per partition, carries each partition's index and, for a stage that reads files, its own copy of the block. That works around Ballista only slicing a fixed list of leaf types per task (apache/datafusion-ballista#2679).
- Main build: nothing in the main build calls any of this yet.
3.
native/native-executors. A new Cargo workspace, with its own lockfile, that builds two binaries on the Ballista 55 crates:-
comet-schedulerwraps Ballista's scheduler in an Arrow Flight service.GetFlightInfotakes aQueryRequest, checks the client's Comet version and plan format, and plans each block with Comet's planner to check it. That builds no object store for the block's files, so the scheduler uses no storage credentials. It then builds a Ballista physical plan, runs it, and returns one endpoint per result partition. Each endpoint carries an opaque ticket forDoGeton the executor that holds the partition, and the time the partition is deleted: Ballista deletes a query's resultsCOMET_SCHEDULER_RESULT_RETENTION_SECONDSafter the query ends (five minutes by default), whether or not they have been read.-
comet-executoris Ballista's executor with Comet's codec. It links no libjvm.- Both take their settings from environment variables, with Ballista's defaults otherwise.
Exchanges map onto Ballista's planner like this, and a stage that reads exchanges has as many partitions as they deliver:
| Exchange | Ballista plan |
| --------------------------- | --------------------------------------------------------------------------------------------- |
| Hash |
RepartitionExec(Hash), partitioned with DataFusion's hash (apache/datafusion-ballista#2681) || Single partition, broadcast |
CoalescePartitionsExec|| Range |
CoalescePartitionsExec, so the sort runs in one task (apache/datafusion-ballista#2680) |4. Tests through Flight.
tests/cluster.rsstarts the two binaries and runs queries the way a driver would.5. CI. A new
linux-test-native-executorsjob runs clippy and the workspace's tests, since the existing Rust jobs don't cover a separate workspace. Thelintjob checks its formatting. The workflow comment and the README say what to do when Comet moves to a DataFusion major that Ballista hasn't released yet: the upgrade can turn the job off until Ballista catches up.Also: the release process now refreshes the new workspace's lockfile along with the others.
Known limits:
How are these changes tested?
tests/assembly.rs(12 tests) runs them with no Ballista. It covers:- a
RangeScanleaf stage feeding hash, range and single-partition exchanges;- the cast of a stage's output to its declared types, and that each batch carries the schema its stage declares, which Ballista's shuffle writer asserts;
- the partition count of a stage that reads an exchange;
- a check of a stage that reads files, which builds no object store;
- rejection of mismatched columns, mismatched partition plans, a stage with no partitions, and a block that calls into the JVM.
tests/cluster.rs(4 tests) startscomet-schedulerandcomet-executorand runs queries through the scheduler's Flight service, reading every result partition withDoGet. It covers a hash shuffle and a range exchange, checks that a query from another Comet build is refused, and checks, with a short retention, that each endpoint says when its partition goes and that a partition no client read is gone after that. It runs in the new CI job.jni_apiunit tests pass. Clippy andcargo macheteare clean for the main workspace, and clippy is clean for the new one.