Add TPC-H distributed plan-stability test suite#1966
Merged
Conversation
Add the 8 TPC-H schemas (copied verbatim from benchmarks/src/bin/tpch.rs), SF100 row-count constants, and staged_plan_text(query_name) which loads a TPC-H query's SQL, registers stats-only tables, builds the physical plan with the Ballista-configured planner (target_partitions=16), splits it into distributed query stages via DefaultDistributedPlanner, and renders the stages to normalized text. Copy the 22 TPC-H query SQL files and add helper tests covering a single-statement query (q1) and a multi-statement query with view DDL (q15).
Add dev/update-tpch-plan-stability.sh to regenerate approved golden plans, and document the suite's scope, usage, and existing CI coverage. No workflow changes needed: rust.yml already runs workspace-wide cargo test/clippy/fmt jobs that pick up the new [[test]] target automatically.
Fix outstanding cargo fmt --check deltas in fixtures.rs, stats_table.rs, and the plan_stability_test! macro invocation in main.rs.
avantgardnerio
approved these changes
Jul 8, 2026
avantgardnerio
left a comment
Contributor
There was a problem hiding this comment.
LGTM. I very much intend to be changing these plans (for the better), but producing the same result. I'm happy to update them though - I think the value of seeing the plans checked in (and changed in PRs) is far higher than the maintenance cost.
Member
Author
This approach has prevented many regressions in Comet from accidental planning changes. It would be nice to expand this to the AQE use case as well. Currently it uses the static planner. |
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?
N/A — adds plan-stability test coverage (analogous to Comet's TPC-DS plan-stability golden files).
Rationale for this change
Ballista has no protection against accidental changes to the distributed plan shape of TPC-H queries. The existing per-query TPC-H tests (
benchmarks/src/bin/tpch.rs) verify query results, not plan structure — a change that alters join strategy, shuffle/stage boundaries, stage count, or broadcast decisions but still returns correct rows passes silently.Comet (and Spark upstream) guard against exactly this with plan-stability golden files: each query's plan is frozen as a checked-in text file and CI fails when it drifts. This PR brings the same protection to Ballista for TPC-H. Concretely, it would have caught plan-shape changes such as a flip in the default join strategy or changes in exchange-reuse stage counts.
What changes are included in this PR?
A new integration test in the
ballista-schedulercrate underballista/scheduler/tests/tpch_plan_stability/:stats_table.rs): aTableProviderwith a real TPC-H schema and injected SF100 row-count statistics (aStatsExecleaf modeled on DataFusion'sEmptyExec), so the physical optimizer makes realistic join/broadcast choices without reading any data.fixtures.rs): the 8 TPC-H schemas, SF100 cardinalities, andstaged_plan_text(), which plans a query with the staticDefaultDistributedPlanner(target_partitions=16, Ballista default config), renders the resulting stages (ShuffleWriterExec/UnresolvedShuffleExecboundaries) to normalized text.main.rs):#[tokio::test]casesq1..q22comparing the live staged plan againstapproved/qN.txt; regenerate withBALLISTA_GENERATE_GOLDEN=1(wrapped bydev/update-tpch-plan-stability.sh).queries/, aREADME.md, and a RAT exclusion for the header-less golden text files.Scope (v1): TPC-H only, static planner, Ballista default config (SortMergeJoin). SHJ / adaptive variants can be added later as sibling golden directories.
Are there any user-facing changes?
No. Test infrastructure only. Adds a developer helper script
dev/update-tpch-plan-stability.shfor regenerating the approved plans after an intended change.