Skip to content

Cypher: WHERE pattern-predicate AND order sensitivity with varlen clauses #1332

@lmeyerov

Description

@lmeyerov

Summary

Direct-Cypher WHERE clauses with conjoined pattern predicates can produce different results depending on operand order when variable-length predicates are involved.

Repro (minimal)

Using a graph with:

  • REL1 chain: a->b->c->d
  • REL2 edges: a->e, b->e

Query A:

MATCH (n)
WHERE (n)-[:REL1*2]->() AND (n)-[:REL2*1]->()
RETURN n.id AS id ORDER BY id

Observed: [{"id": "b"}]

Query B (same operands swapped):

MATCH (n)
WHERE (n)-[:REL2*1]->() AND (n)-[:REL1*2]->()
RETURN n.id AS id ORDER BY id

Observed: []

Expected

AND should be order-invariant for logically equivalent predicates.

Context

Initial hypothesis

Lowering/evaluation for where-pattern rewrites may be order-sensitive when mixing multiple pattern predicates, likely around semi-apply marker/filter sequencing.

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