Skip to content

Split PushDownFilter::rewrite into per-plan-node pushdown helpers #26305

Open

Description

@andygrove

Is your feature request related to a problem or challenge?

PushDownFilter::rewrite (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 0d79252.

Activity

  1. added
    enhancementNew feature or request
    help wantedExtra attention is needed
    tech debtCode complexity, duplication or structure that makes the codebase harder to change
    on Oct 14, 2026
  2. mohitgurav20 commented on Oct 14, 2026

    @mohitgurav20
    Contributor

    take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededoptimizerOptimizer rulestech debtCode complexity, duplication or structure that makes the codebase harder to change

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions