Skip to content

M4-PR3: implement PredicatePushdownPass rewrite using pass framework + safety primitives #1187

@lmeyerov

Description

@lmeyerov

Parent: #1179
Depends on: #1180 (pass framework), #1181 (pushdown safety primitives)

Objective

Implement the actual PredicatePushdownPass logical-plan rewrite now that framework and safety primitives are merged.

Scope

  • Add PredicatePushdownPass implementation under graphistry/compute/gfql/passes/.
  • Rewrite Filter(input=PatternMatch(...)) by pushing safe predicates into PatternMatch.predicates.
  • Respect OPTIONAL MATCH null-extension semantics via existing safety helpers in gfql/ir/pushdown_safety.py.
  • Respect WITH/ScopeFrame barriers (no pushdown across scope-reset boundaries).
  • Keep pass pure (no in-place mutation).

Acceptance

  • Safe predicates are pushed into PatternMatch.predicates and residual predicates remain as Filter when only partially pushable.
  • Null-rejecting predicates on optional-arm aliases are not pushed into optional arms.
  • WITH-boundary barrier blocks pushdown where required.
  • Pass executes through PassManager and verifier remains green after pass application.
  • No semantic regression in existing Cypher OPTIONAL behavior tests.

Test Gate

  • Unit tests for full-push, partial-push, and no-push cases.
  • Negative tests proving optional-arm null-rejecting predicates stay above optional match.
  • Boundary tests proving WITH/ScopeFrame blocks backward pushdown.
  • Integration test proving logical plan flows through pass manager and produces stable output plan shape.

Non-goals

  • No IndexRewritePass in this issue.
  • No broad cost-based optimization work in this issue.
  • No physical planner route changes in this issue.

Notes

  • Prefer small deterministic rewrites and explicit plan-shape assertions in tests.
  • If discovered edge cases require additional safety helper extensions, track those in this PR scope only when directly required for predicate pushdown correctness.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions