← Back to Pull requests

feat: add comet-scheduler and comet-executor for Comet Native Executors #7299

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Oct 28, 2026 14:32 UTC
Author

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.proto defines QueryRequest: 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. Fragment carries a stage from the scheduler to its executors. The proto crate exports a fingerprint of the .proto files, so a cluster can refuse a query from another Comet build.
2. Native blocks outside Spark. CometFragmentExec runs 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_data plans 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-scheduler wraps Ballista's scheduler in an Arrow Flight service. GetFlightInfo takes a QueryRequest, 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 for DoGet on the executor that holds the partition, and the time the partition is deleted: Ballista deletes a query's results COMET_SCHEDULER_RESULT_RETENTION_SECONDS after the query ends (five minutes by default), whether or not they have been read.
- comet-executor is 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.rs starts the two binaries and runs queries the way a driver would.
5. CI. A new linux-test-native-executors job runs clippy and the workspace's tests, since the existing Rust jobs don't cover a separate workspace. The lint job 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:

  • A stage that several other stages read runs once for each of them, because Ballista's planner doesn't share a stage between consumers yet.

  • Nothing cancels a query whose client goes away. Cancellation comes with the driver side.

  • A query's results are deleted when their retention runs out, not once the client has read them. Releasing them when read also comes with the driver side.

  • Other Ballista changes this will want are apache/datafusion-ballista#2678 (AQE for submitted physical plans) and the issues linked above.
  • How are these changes tested?

  • Stage graphs on DataFusion alone: tests/assembly.rs (12 tests) runs them with no Ballista. It covers:

  • - a RangeScan leaf 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.
  • The binaries through Flight: tests/cluster.rs (4 tests) starts comet-scheduler and comet-executor and runs queries through the scheduler's Flight service, reading every result partition with DoGet. 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.

  • End to end from Spark: #7289 holds this PR's commits with the driver side on top, and its Spark suite passes against these binaries. It runs scans, aggregates, shuffled joins and TPC-H q1 on SF1 data from a Spark driver.

  • Existing tests: the core planner and jni_api unit tests pass. Clippy and cargo machete are clean for the main workspace, and clippy is clean for the new one.
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: sunchao Review duration: 5517m
    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
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.7% · Safe to merge
    27.7%