Skip to content

Commit 6b11d89

Browse files
kyleconroyclaude
andcommitted
Add SHORTEST_PATH graph query pattern support
- Add GraphMatchRecursivePredicate, GraphRecursiveMatchQuantifier, and GraphMatchLastNodePredicate AST types for SHORTEST_PATH patterns - Implement parseGraphMatchShortestPath for parsing SHORTEST_PATH(pattern+) and SHORTEST_PATH(pattern{min,max}) with both anchor-on-left and anchor-on-right syntax variants - Add support for LAST_NODE() function in graph patterns - Add FOR PATH table reference modifier for graph path queries - Add GRAPH PATH option support for WITHIN GROUP clause - Add JSON marshaling for all new graph match types Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 0d5a7ea commit 6b11d89

4 files changed

Lines changed: 400 additions & 24 deletions

File tree

ast/merge_statement.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,35 @@ type GraphMatchNodeExpression struct {
105105

106106
func (g *GraphMatchNodeExpression) node() {}
107107
func (g *GraphMatchNodeExpression) graphMatchExpression() {}
108+
109+
// GraphMatchRecursivePredicate represents SHORTEST_PATH graph pattern
110+
type GraphMatchRecursivePredicate struct {
111+
Function string // "ShortestPath"
112+
OuterNodeExpression *GraphMatchNodeExpression
113+
Expression []*GraphMatchCompositeExpression
114+
RecursiveQuantifier *GraphRecursiveMatchQuantifier
115+
AnchorOnLeft bool
116+
}
117+
118+
func (g *GraphMatchRecursivePredicate) node() {}
119+
func (g *GraphMatchRecursivePredicate) graphMatchExpression() {}
120+
func (g *GraphMatchRecursivePredicate) booleanExpression() {}
121+
122+
// GraphRecursiveMatchQuantifier represents the quantifier in SHORTEST_PATH (+ or {min,max})
123+
type GraphRecursiveMatchQuantifier struct {
124+
IsPlusSign bool
125+
LowerLimit ScalarExpression
126+
UpperLimit ScalarExpression
127+
}
128+
129+
func (g *GraphRecursiveMatchQuantifier) node() {}
130+
131+
// GraphMatchLastNodePredicate represents LAST_NODE(x) = LAST_NODE(y)
132+
type GraphMatchLastNodePredicate struct {
133+
LeftExpression *GraphMatchNodeExpression
134+
RightExpression *GraphMatchNodeExpression
135+
}
136+
137+
func (g *GraphMatchLastNodePredicate) node() {}
138+
func (g *GraphMatchLastNodePredicate) graphMatchExpression() {}
139+
func (g *GraphMatchLastNodePredicate) booleanExpression() {}

0 commit comments

Comments
 (0)