Skip to content

Prune named paths by any per-relationship condition in all() and none() #207

Done

Description

@prrao87

Problem or use case

#205 makes WHERE all(r IN relationships(p) WHERE ...) on a named variable-length path drop a failing relationship during the walk, but only for equalities on r (r.day = 5, r.kind = $kind). Any other condition on a single relationship is still checked once each path is complete, so its cost follows the unfiltered fan-out, as in #179:

MATCH p = (c:Computer {host_id: 17693})-[:AUTH*1..3]->(d:Computer)
WHERE all(r IN relationships(p) WHERE r.day >= 5 AND r.day <= 7)
RETURN count(*)

The same holds for:

  • ranges and other comparisons: r.weight > 0.5, r.day <> 3;
  • IN lists: r.kind IN ['login', 'ticket'];
  • OR inside the predicate: r.day = 5 OR r.day = 6;
  • none(r IN relationships(p) WHERE x), which means the same as all(r IN relationships(p) WHERE NOT x).

Each of these is a check on one relationship, so a failing edge could end its branch just as an equality does.

Proposed improvement

Let the named-path operator take any per-relationship condition, not only key/value equalities. For each step it would hold one DataFusion expression over the relationship columns, built from the all()/none() predicate with r.key rewritten to the column key. That expression then builds the per-edge mask the walk already checks.

  • Which predicates qualify: those that refer only to r's properties, parameters and literals.
  • Parameter binding: the expressions must stay visible to the per-execution parameter binding from fix(cypher): bind cached path filters per execution #197.
  • What stays out of scope: any, single, and an all() term under OR or NOT can't drop an edge during the walk, so they keep filtering afterwards.

Activity

  1. added
    enhancement
    on Nov 25, 2026
  2. added a commit that references this issue on Nov 26, 2026
    8b0bf0d
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions