andygrove opened a new issue, #26305: URL: https://github.com/apache/datafusion/issues/26305
### Is your feature request related to a problem or challenge? [`PushDownFilter::rewrite` (push_down_filter.rs#L860-L1477)](https://github.com/apache/datafusion/blob/0d79252f61bd8777990b2749c216ffd07079c30d/datafusion/optimizer/src/push_down_filter.rs#L860-L1477) is a 463-line function with cyclomatic complexity 70 and cognitive complexity 110, and `push_down_filter.rs` has had 44 commits in the last 12 months. It first simplifies and reorders the predicates (about L874-L917, including a subtle `predicates_changed` computation at about L895-L909), handles FALSE and fetch/skip early-outs, and then matches on the child plan. Simple arms (Sort, Repartition, Distinct) are fine, but several inline multi-step pushdown logic: SubqueryAlias column remapping (about L986-L1004), Unnest predicate classification (about L1018-L1084), Aggregate (about L1115), Window (about L1171), AsOfJoin (about L1261), TableScan (about L1315) and Extension (about L1401). Every new plan type or pushdown tweak touches this one function, and the large arms can't be unit tested on their own. ### Describe the solution you'd like Keep `rewrite` as a dispatcher. Extract the preamble into `simplify_filter_predicates(&mut Filter) -> Result<bool>`, and move each non-trivial arm into a free function following the existing `push_down_all_join` / `rewrite_projection` pattern: `push_down_subquery_alias`, `push_down_unnest`, `push_down_through_aggregate`, `push_down_through_window`, `push_down_through_asof_join`, `push_down_into_table_scan`, `push_down_through_extension`. Optionally turn the file into a module directory (join, scan, simplify). ### Describe alternatives you've considered Leave it as is. ### Additional context Line references are pinned to commit 0d79252f61bd. -- 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]
