fix(examples): apply relation aliases once - #24756
Draft
geoffreyclaude wants to merge 2 commits into
Draft
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #24756 +/- ##
==========================================
- Coverage 81.48% 81.48% -0.01%
==========================================
Files 1122 1122
Lines 404248 404248
Branches 404248 404248
==========================================
- Hits 329390 329386 -4
Misses 55547 55547
- Partials 19311 19315 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
RelationPlanning::Planned and RelationPlanning::Original began taking boxed values in apache@e8efd59, merged through apache#19672. The extending SQL guide retained the old constructors, so update the example to match the current API.
geoffreyclaude
force-pushed
the
codex/relation-alias-once
branch
from
August 28, 2026 14:55
6c73d46 to
9e3f228
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?
Rationale for this change
The official
TABLESAMPLErelation-planner example currently applies a relation alias twice. It recursively plans the underlying table while the alias is still attached, then returns that same alias with the completed sampled plan.RelationPlannerContext::plan(...)applies the first copy, and DataFusion appliesPlannedRelation::aliasa second time.This is subtle enough to miss in review, and the example is doing its job a little too well: VGI copied the same recursive-planning shape and returns the alias again.
The intended ownership rule is simple: remove the outer alias before recursively planning an inner relation, then return that alias with the finished extension plan so DataFusion applies it once, around the whole relation.
What changes are included in this PR?
TABLESAMPLEexample so the recursively planned base relation has no alias.PlannedRelationandRelationPlannerContext::planAPI docs and in the extending-SQL guide.RelationPlanningexample to use the current boxed variants.Are these changes tested?
Yes. The test checks the complete logical-plan shape and verifies that the relation alias and each column rename appear exactly once. As an ablation check, restoring the old
alias.clone()line makes the test fail with twoSubqueryAliasnodes and duplicate rename projections.I also ran the focused example test, example compilation,
cargo fmt --all, the required all-target/all-feature Clippy command with warnings denied, Rustdoc fordatafusion-expr, and the documentation Prettier check.Are there any user-facing changes?
The core planner's alias behavior is unchanged. The user-facing changes are a corrected official example and clearer documentation for extension authors.