Skip to content

Graph Analytical View multi-hop traversals ignore Cypher relationship uniqueness: the same edge is bound twice in one MATCH #8394

Closed

Description

@lvca

Summary

Found while fixing #8377. With a Graph Analytical View READY, every multi-hop Cypher pattern whose hops share an edge type ignores Cypher relationship uniqueness (a relationship may be bound only once per MATCH). The CSR holds adjacency ids, not edge identities, so GAVExpandAll and GAVFusedChainOperator cannot tell a hop's edge from one a preceding same-clause hop already bound. GAVExpandInto already declines for this reason (CypherOptimizer.createExpandIntoOperator, the sameClausePrecedingRelVars guard), but createExpandAllOperator picks GAVExpandAll for any hop whose edge is not materialized, and an anonymous hop in the needsEdgeTracking set is exactly that. Since the GAV hop registers no synthetic edge-tracking variable, a later ExpandInto/GAVExpandInto/VarLengthExpand of the same clause and the cross-component RelationshipUniquenessFilter see no preceding edges either.

Repro

30 P vertices, each with a self-loop and 3 random K edges; CREATE GRAPH ANALYTICAL VIEW pv VERTEX TYPES (P) EDGE TYPES (K) PROPERTIES (id):

query no view view
MATCH (a:P)-[:K]->(b:P)-[:K]->(c:P) RETURN count(*) 448 480
MATCH (a:P)-[:K]-(b:P)-[:K]-(c:P) RETURN count(*) 1320 2006
MATCH (a:P)-[:K]->(b:P), (a)-[:K]->(c:P) RETURN count(*) 360 480
MATCH (a:P)-[:K]->(b:P)-[:K]->(c:P)-[:K]->(d:P) RETURN count(*) 1685 1920
MATCH (a:P {id:1})-[:K]-(b:P)-[:K]-(c:P) RETURN count(*) 39 58

The undirected friends-of-friends shape is the most exposed: every c = a reached back over the same edge is returned. A directed chain is hit through self-loops, a branching pattern whenever both branches land on the same neighbour.

Direction

Two options:

  1. Decline GAV for any hop in needsEdgeTracking (and never fuse such a chain). Correct, but it gives up the view for same-type chains, which is its main use case.
  2. Give the GAV operators edge identities. An anonymous hop never exposes its edge, so a canonical label is enough: (edgeType, src, tgt, occurrence), where occurrence is the rank of this parallel edge among entries equal to the neighbour in the per-type adjacency list being walked. A hop conflicts with a bound edge only when the endpoints match, so the check stays an int comparison against at most depth entries on the hot path. The occurrence is computed only on a match. The GAV hops then have to expose these identities to the later same-clause operators (ExpandInto, VarLengthExpand, the cross-component filter), or the optimizer keeps those hops off GAV when a GAV hop precedes them.

Option 2 is the right one. It needs per-type neighbour lists from the provider (today getNeighborIds(node, dir, types) concatenates types, so equal neighbours from different types would collide).

Activity

  1. added this to the 26.10.1 milestone on Sep 25, 2026
  2. added
    severity:major
    in progress
    on Sep 25, 2026
  3. self-assigned this
    on Sep 25, 2026
  4. added 11 commits that reference this issue on Sep 25, 2026
  5. lvca commented on Sep 26, 2026

    @lvca
    MemberAuthor

    Fixed in #8425 (26.10.1).

    With a Graph Analytical View, a multi-hop pattern such as MATCH (a)-[:KNOWS]-(b)-[:KNOWS]-(c) could use the same relationship twice, returning more rows than the same query without the view. The view now remembers which relationship each hop took, so results always match the query without the view, still served from the view.

    A clause falls back to the regular (non-view) traversal when it needs the actual edge: a named relationship variable, a variable-length relationship, or an edge type with sub-types. An undirected chain that counted a self-loop twice is fixed too.

    A related gap with edge sub-types is tracked in #8426.


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  6. removed
    in progress
    on Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugopencypherseverity:major

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions