Skip to content

fix: triadic friend-of-friend pattern matching #302

@DecisionNerd

Description

@DecisionNerd

Summary

Triadic selection patterns (friend-of-friend queries that exclude direct connections) do not return correct results. These patterns have the form:

MATCH (a:Person)-[:KNOWS]->(b)-[:KNOWS]->(c)
WHERE NOT (a)-[:KNOWS]->(c) AND a <> c
RETURN c

The issue is in how the executor handles negative pattern predicates (WHERE NOT (pattern)) when checking for existing relationships.

TCK Impact

~19 scenarios

Effort

Medium — executor changes to pattern predicate evaluation

Acceptance Criteria

  • WHERE NOT (a)-[:R]->(b) correctly excludes nodes with the relationship
  • Triadic selection returns correct results
  • Variable-length path exclusion works
  • Combinations of positive and negative pattern predicates work

v0.3.8 Planning

Phase: 7 — Pattern Predicates + Triadic Selection
PR branch: fix/306-302-pattern-predicates-triadic
Milestone: v0.3.8
Est. TCK gain: +12–15 (of the combined +20–25 for Phase 7; PR #364 addressed partial cases)
Effort: Part of 2–3 day combined effort
Depends on: Phase 4 (#370), Phase 7 (#306 pattern predicate foundation must land in same PR)
Primary files: src/graphforge/executor/evaluator.py, src/graphforge/planner/planner.py
Verify: uv run pytest tests/tck/ -k "triadic or friend" -v

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingexecutorChanges to query executor

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions