Skip to content

GQL Phase B: full Quantified Path Patterns (multi-hop inner, inner WHERE, group-variable LIST bindings, grouped path assignment) #4531

Description

@lvca

Split out from #4141 (GQL ISO/IEC 39075 conformance roadmap) so that issue can be closed with the shipped items. This tracks the remaining Core Syntax & DML - Phase B work: the full Quantified Path Patterns (QPP) feature that cannot be lowered onto the existing variable-length-relationship machinery.

Background

QPP is GQL / Cypher 25's generalization of variable-length relationships: a parenthesized inner pattern with a quantifier, e.g.

MATCH (a) ( (x)-[:KNOWS]->(y) ){1,3} (b)

Phase A is already shipped (#3365 / 26.5.1): the single-relationship case ( (a)-[:R]->(b) )+ is lowered onto ArcadeDB's existing variable-length-path engine, since a one-edge group is functionally identical to -[:R*]->.

Phase B (this issue) is everything that cannot be faked by that lowering. These cases are currently rejected with FeatureNotImplemented in CypherASTBuilder.absorbParenthesizedPath (engine, ~lines 1683-1714).

Scope

1. Quantified Path Patterns - Phase B

  • Multi-relationship inner patterns - the repeated unit is a 2+ hop path, not a single edge:
    MATCH ( (a)-[:R1]->(b)-[:R2]->(c) )+
    Cannot collapse to a single -[*]->; needs a real repeated-subpattern matcher. (Rejected today with FeatureNotImplemented: only single-relationship inner patterns are supported ....)
  • Inner WHERE predicates on the parenthesized path, evaluated per repetition:
    MATCH ( (a)-[r]->(b) WHERE r.weight > 5 )+
    (Rejected today with FeatureNotImplemented: WHERE inside a quantified path pattern ....)
  • Label-divergent endpoints / richer inner structure - inner nodes with different labels per side, etc.
  • Inner-node variable bindings as LIST<NODE> - GQL "group variable" semantics: variables bound inside the group surface outside as parallel lists, one element per repetition. Same for relationship variables (LIST<RELATIONSHIP>):
    MATCH (a) ( (x)-[:R]->(y) ){2} (b)
    RETURN x   // x is a LIST<NODE> [x1, x2], not a single node

2. Grouped Path Assignments - Phase B

  • Per ISO/IEC 39075 §15.4, a path variable bound to a quantified group should yield LIST<PATH> (one path per repetition):
    MATCH p = ( (a)-[:R]->(b) )+
    RETURN p
    Phase A binds p to a single concatenated path (matching pre-existing variable-length behavior); Phase B should bind it to a list of per-iteration paths.

Why this is the hard part

Phase A worked by reusing the variable-length relationship engine. Phase B cannot: it needs a genuine repeated-subpattern execution operator that (a) matches an arbitrary inner pattern N times, (b) threads inner WHERE predicates per iteration, and (c) collects each iteration's bindings into parallel group-variable lists. That is net-new execution machinery plus a new result-typing concept (LIST<NODE> / LIST<RELATIONSHIP> / LIST<PATH>).

Note: the OpenCypher engine has both an optimizer path and a legacy execution path; a new pattern operator likely needs wiring in both, plus group-variable threading through projection.

Key files

  • engine/src/main/java/com/arcadedb/query/opencypher/parser/CypherASTBuilder.java - absorbParenthesizedPath (current Phase B rejections live here)
  • engine/src/main/antlr4/com/arcadedb/query/opencypher/grammar/Cypher25Parser.g4 - parenthesizedPath, quantifier, pathPattern rules (grammar already parses the full form)
  • engine/src/main/java/com/arcadedb/query/opencypher/executor/, optimizer/, planner/ - where a repeated-subpattern operator would slot in

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Fields

No fields configured for Feature.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions