Skip to content

Display input stage id on UnresolvedShuffleExec#1969

Merged
andygrove merged 1 commit into
apache:mainfrom
andygrove:unresolved-shuffle-stage-id
Jul 9, 2026
Merged

Display input stage id on UnresolvedShuffleExec#1969
andygrove merged 1 commit into
apache:mainfrom
andygrove:unresolved-shuffle-stage-id

Conversation

@andygrove

Copy link
Copy Markdown
Member

Which issue does this PR close?

Closes #1967.

Rationale for this change

When viewing distributed plans, UnresolvedShuffleExec renders only its partitioning, so it isn't obvious which input stage it reads from:

UnresolvedShuffleExec: partitioning: Hash([c_custkey@0], 16)

Including the input stage id makes the stage graph legible directly from the plan text (and from EXPLAIN/plan-stability snapshots):

UnresolvedShuffleExec: stage=3, partitioning: Hash([c_custkey@0], 16)

What changes are included in this PR?

  • UnresolvedShuffleExec's Display (fmt_as, Default/Verbose) now prefixes stage=N in both the partitioning and broadcast forms, using the existing stage_id field. The TreeRender form is unchanged.
  • This is a display-only change — serialization uses the stage_id struct field, not the Display string, so plan reconstruction is unaffected.
  • Updated the affected inline plan-string assertions in planner.rs and client/tests/context_checks.rs, and regenerated the TPC-H plan-stability goldens (the only change is the added stage=N annotation; stage counts are unchanged).

Are there any user-facing changes?

Plan text (e.g. EXPLAIN, executor logs) now shows the input stage id on UnresolvedShuffleExec. No API changes.

Render `stage=N` in UnresolvedShuffleExec's Display output so
distributed plans show which input stage each unresolved shuffle
reads from. This is a text-only change; the stage_id field already
existed and drives serialization, which is unaffected.

Update hardcoded plan-string assertions and doc comments in
planner.rs and context_checks.rs to match, and regenerate the TPC-H
plan-stability goldens (only adds `stage=N,` annotations; stage
counts are unchanged).

@milenkovicm milenkovicm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks @andygrove

@andygrove andygrove merged commit 5298a9f into apache:main Jul 9, 2026
15 checks passed
@andygrove andygrove deleted the unresolved-shuffle-stage-id branch July 9, 2026 04:19
andygrove added a commit to andygrove/datafusion-ballista that referenced this pull request Jul 9, 2026
apache/main now contains apache#1969, the standalone merge of the same
UnresolvedShuffleExec stage-id display feature this branch carries in
841d1b2. The display change is identical on both sides; the auto-merge
duplicated the new display_includes_stage_id test, so the redundant copy
is removed here. Plan-stability goldens regenerated with
dev/update-tpch-plan-stability.sh: no golden changes (reuse-aware plans
already match the merged code); 26/26 tpch_plan_stability tests pass.
andygrove added a commit to andygrove/datafusion-ballista that referenced this pull request Jul 9, 2026
…nge analog)

Detect repeated shuffle exchanges during static graph planning and route
their consumers to a single shared producer stage, the distributed analog
of Spark's ReuseExchange. Identical exchange subtrees (matched by a shared
protobuf_canonical_key) collapse to one ShuffleWriter stage instead of
being recomputed per consumer, cutting stage count and redundant shuffle
work on queries with common sub-plans (e.g. TPC-H q2, q11, q15).

- add ballista.optimizer.reuse_exchange_enabled config (default on)
- add reuse_shuffle_stages pass and run it in ExecutionGraph planning
- extract shared protobuf_canonical_key as the single fingerprint source
- make the TPC-H plan-stability suite reuse-aware (fixture applies the
  reuse pass; goldens q2/q11/q15 regenerated; add
  exchange_reuse_reduces_stage_count assertion)

Rebased onto apache/main; the redundant apache#1967 stage-id display commit is
dropped as main now carries it via apache#1969.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UnresolvedShuffleExec should display the input stage number

2 participants