Refactor unary filter pushdown logic for Aggregate and Window#22060
Open
kosiew wants to merge 3 commits intoapache:mainfrom
Open
Refactor unary filter pushdown logic for Aggregate and Window#22060kosiew wants to merge 3 commits intoapache:mainfrom
kosiew wants to merge 3 commits intoapache:mainfrom
Conversation
…y operators - Implemented `push_down_filter_through_unary` helper function. - Migrated Aggregate and Window optimizations to use the new helper. - Maintained existing behavior and flags for consistency.
- Removed unary_input parameter from push_down_filter_through_unary. - Introduced insert_filter_below_unary to derive child from unary_plan. - Simplified Aggregate/Window call sites. - Eliminated potential mismatch risk.
- Inlined classifier temps for improved performance. - Replaced replace_map loop with an iterator collect for better efficiency. - Added new method map_single_child to streamline child processing. - Integrated map_single_child in both insert_filter_below_unary and insert_below functions.
2186e2f to
20b8885
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
PushDownFiltercontained duplicated logic in theAggregateandWindowbranches for: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?
push_down_filter_through_unary, to encapsulate the common unary filter pushdown pattern.insert_filter_below_unaryhelper for inserting filters beneath unary plan nodes.Aggregatebranch to use the shared helper while preserving aggregate-specific expression rewriting viareplace_cols_by_name.Windowbranch to use the shared helper while preserving existing partition-key eligibility checks.map_single_child.insert_belowto 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_filtercargo test -p datafusion-sqllogictest --test sqllogictests push_down_filter_regressionAre 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.