Skip to content

openCypher: label expressions with ! / % / mixed &| on variable-length relationships ([r:!R*], shortestPath) are refused #9117

Closed

Description

@robfrank

Follow-up of #8992.

The fix for #8992 evaluates the full label expression (!, %, and & mixed with |) on node patterns, single-hop relationship patterns, quantified path patterns, pattern predicates, pattern comprehensions and in WHERE. It does so by turning the expression into a predicate over the element, which the single-hop steps already evaluate per relationship.

A variable-length relationship has no such per-hop predicate in the expansion steps (ExpandPathStep, VarLengthExpand, ShortestPathStep's hop filter works on the type list only), so these shapes are now refused at parse time with an error that names the expression, instead of silently dropping the operator as before #8992:

MATCH (a)-[:!R*1..3]->(b) RETURN b
MATCH p = shortestPath((a)-[:!R*]-(b)) RETURN p
MATCH (a)-[:(R|S)&!T*]->(b) RETURN b

Neo4j evaluates the expression against every relationship of the path. Supporting it needs the variable-length expansion to filter each hop with a LabelPredicate (or the type list to be resolved against the schema's edge types at plan time, which a relationship's single type makes possible).

Entry point: CypherASTBuilder.visitRelationshipPattern / CypherExpressionBuilder.parseRelationshipPattern, the pathLength != null branch that throws.

Activity

  1. added
    enhancement
    on Oct 3, 2026
  2. added
    severity:minor
    on Oct 3, 2026
  3. modified the milestones: 26.10.1, 26.11.1 on Oct 4, 2026
  4. self-assigned this
    on Oct 7, 2026
  5. added
    in progress
    on Oct 7, 2026
  6. robfrank commented on Oct 8, 2026

    @robfrank
    CollaboratorAuthor

    Fixed by #9477. Label expressions on variable-length relationships now run instead of being refused at parse time: [:!R*1..3], [:%*], [:(R|S)&!T*], and inside shortestPath/allShortestPaths, pattern predicates and pattern comprehensions. The expression is checked at every hop, on both the legacy and the optimized execution paths.

    Performance note: an expression that needs a per-hop check (!, %, or & mixed with |) does not get the faster VarLengthExpand path, and [:!R*] expands over every relationship type. A plain type list such as [:R|S*] is unchanged. The fix is complete.


    ❤️ 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.

  7. removed
    in progress
    on Oct 8, 2026
  8. added a commit that references this issue on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementopencypherseverity:minor

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions