Skip to content

Commit c5257f0

Browse files
authored
fix: preserve computed projections in unions_to_filter (#25074)
## Which issue does this PR close? - Closes #25071 ## Rationale for this change With `enable_unions_to_filter` enabled, `UNION DISTINCT` branches containing different computed projections below their filters can be incorrectly treated as equivalent. This produces wrong result values and row counts without an error. ## What changes are included in this PR? `unions_to_filter` now skips the rewrite when a projection appears below a branch filter. Alias nodes remain safe to strip. A regression test covers branches computing `a + 100` and `a + 200` below their filters. ## What is the testing strategy for this PR? - `cargo +1.97.0-x86_64-pc-windows-gnullvm test --locked -p datafusion-optimizer unions_to_filter --lib` (9 passed) - The standalone reproducer returns `[1100, 1200]` with the optimizer setting both disabled and enabled after the fix. - `git diff --check` ## Are there any user-facing changes? This prevents incorrect query results when the opt-in `unions_to_filter` optimizer rule is enabled.
1 parent e4c4fa4 commit c5257f0

2 files changed

Lines changed: 534 additions & 51 deletions

File tree

0 commit comments

Comments
 (0)