discord9 opened a new pull request, #22926:
URL: https://github.com/apache/datafusion/pull/22926

   ## Which issue does this PR close?
   
   - Closes #22925.
   
   ## Rationale for this change
   
   `FilterPushdown` maps child pushdown results back to the original parent 
filters by position.
   
   `AggregateExec::gather_filters_for_pushdown` was splitting incoming parent 
filters into safe and unsafe buckets, building the child filter description 
from the safe filters, and then appending unsupported unsafe filters. For mixed 
predicates this reordered the parent filter results.
   
   For example, for a predicate above an aggregate such as `cnt@2 = 1 AND b@1 = 
bar`, the filter on the grouping column `b` can be pushed below the aggregate, 
but the filter on aggregate output `cnt` must remain above it. If the returned 
parent filter results are reordered, the optimizer can treat the pushed-down 
grouping-column filter result as if it belonged to the aggregate-output filter 
and incorrectly remove the aggregate-output filter.
   
   ## What changes are included in this PR?
   
   - Preserve the original `parent_filters` order in 
`AggregateExec::gather_filters_for_pushdown`.
   - Build the child filter description from all parent filters, then mark 
aggregate-unsafe filters as unsupported in place.
   - Add a regression test for a mixed aggregate-output and grouping-column 
predicate.
   
   ## Are these changes tested?
   
   Yes:
   
   - `cargo fmt --all`
   - `cargo fmt --all -- --check`
   - `cargo test -p datafusion --test core_integration 
physical_optimizer::filter_pushdown::test_pushdown_through_aggregates`
   - `cargo clippy --all-targets --all-features -- -D warnings`
   
   ## Are there any user-facing changes?
   
   No.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to