You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "geoffreyclaude (via GitHub)" <gi...@apache.org> on 2026/08/28 13:58:31 UTC
[PR] fix(examples): apply relation aliases once [datafusion]
geoffreyclaude opened a new pull request, #24756:
URL: https://github.com/apache/datafusion/pull/24756
## Which issue does this PR close?
- Closes #24753.
## Rationale for this change
The official `TABLESAMPLE` relation-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 applies `PlannedRelation::alias` a 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](https://github.com/Query-farm/vgi-datafusion/blob/c6e3a6cfb05202a61233aa535912d8e2faae3e6e/src/sampling.rs#L32-L65) and [returns the alias again](https://github.com/Query-farm/vgi-datafusion/blob/c6e3a6cfb05202a61233aa535912d8e2faae3e6e/src/sampling.rs#L131-L133).
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?
- Repair the `TABLESAMPLE` example so the recursively planned base relation has no alias.
- Explain alias ownership in the `PlannedRelation` and `RelationPlannerContext::plan` API docs and in the extending-SQL guide.
- Repair the guide's stale `RelationPlanning` example to use the current boxed variants.
- Add a regression test for an alias with a column list.
## 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 two `SubqueryAlias` nodes 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 for `datafusion-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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix(examples): apply relation aliases once [datafusion]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #24756:
URL: https://github.com/apache/datafusion/pull/24756#issuecomment-5453717317
## [Codecov](https://app.codecov.io/gh/apache/datafusion/pull/24756?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 81.47%. Comparing base ([`4d3e79e`](https://app.codecov.io/gh/apache/datafusion/commit/4d3e79e0b55ee8e7b2ec6d298c662a0b5cff7172?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`6c73d46`](https://app.codecov.io/gh/apache/datafusion/commit/6c73d4604b76d1e858c0b8aa4088dd7ae311aa05?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #24756 +/- ##
==========================================
- Coverage 81.48% 81.47% -0.01%
==========================================
Files 1122 1122
Lines 404248 404248
Branches 404248 404248
==========================================
- Hits 329390 329381 -9
- Misses 55547 55552 +5
- Partials 19311 19315 +4
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/datafusion/pull/24756?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org