Skip to content

fix: Add a subquery when unparsing a Filter depending on a Projection - #25549

Open
nuno-faria wants to merge 2 commits into
apache:mainfrom
nuno-faria:fix_unparser_filter_projection
Open

nuno-faria wants to merge 2 commits into
apache:mainfrom
nuno-faria:fix_unparser_filter_projection

Conversation

@nuno-faria

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

When we have a Filter next to a Projection, we might not be able to unparse them at the same level if the predicate depends on columns aliased by the projection. For those cases, we need to add a subquery in between.

What changes are included in this PR?

  • Iff any column of a Filter is aliased by a Projection directly below it, a subquery is added with derive.

What is the testing strategy for this PR?

Unit tests.

Are there any user-facing changes?

No, this only adds the subquery when it is necessary, so existing tests remain unchanged.

@github-actions github-actions Bot added sql SQL Planner core Core DataFusion crate labels Sep 20, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.41%. Comparing base (99af44a) to head (9285594).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25549      +/-   ##
==========================================
- Coverage   82.41%   82.41%   -0.01%     
==========================================
  Files        1138     1138              
  Lines      435299   435317      +18     
  Branches   435299   435317      +18     
==========================================
+ Hits       358749   358759      +10     
- Misses      54840    54848       +8     
  Partials    21710    21710              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate sql SQL Planner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unparsing of filter on subquery generates invalid SQL

2 participants