kosiew opened a new pull request, #22060: URL: https://github.com/apache/datafusion/pull/22060
## Which issue does this PR close? * Part of #22056 ## Rationale for this change `PushDownFilter` contained duplicated logic in the `Aggregate` and `Window` branches for: * Splitting predicates into pushable and retained sets. * Rebuilding unary plans with pushed filters below them. * Re-applying retained predicates above the rebuilt plan. This change extracts the shared unary pushdown/rebuild flow into reusable internal helpers to reduce duplication and improve maintainability, while preserving existing optimizer behavior. ## What changes are included in this PR? * Added a new internal helper, `push_down_filter_through_unary`, to encapsulate the common unary filter pushdown pattern. * Added `insert_filter_below_unary` helper for inserting filters beneath unary plan nodes. * Refactored the `Aggregate` branch to use the shared helper while preserving aggregate-specific expression rewriting via `replace_cols_by_name`. * Refactored the `Window` branch to use the shared helper while preserving existing partition-key eligibility checks. * Extracted reusable single-child replacement logic into `map_single_child`. * Simplified `insert_below` to reuse the new helper. No intended SQL behavior changes are included in this PR. ## Are these changes tested? No new tests were added in this PR. This refactor is intended to preserve existing behavior and is expected to be covered by the existing optimizer test suite, including: * `cargo test -p datafusion-optimizer push_down_filter` * `cargo test -p datafusion-sqllogictest --test sqllogictests push_down_filter_regression` ## Are there any user-facing changes? No. This change is limited to optimizer internals and does not intend to change SQL semantics or user-visible behavior. ## LLM-generated code disclosure This PR includes LLM-generated code and comments. All LLM-generated content has been manually reviewed and tested. -- 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]
