-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
ClauseConverters.scala
512 lines (417 loc) · 22.5 KB
/
ClauseConverters.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
/*
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.cypher.internal.compiler.v3_1.ast.convert.plannerQuery
import org.neo4j.cypher.internal.compiler.v3_1.ast.ResolvedCall
import org.neo4j.cypher.internal.compiler.v3_1.ast.convert.plannerQuery.ExpressionConverters._
import org.neo4j.cypher.internal.compiler.v3_1.ast.convert.plannerQuery.PatternConverters._
import org.neo4j.cypher.internal.compiler.v3_1.pipes.{HasHeaders, NoHeaders}
import org.neo4j.cypher.internal.compiler.v3_1.planner._
import org.neo4j.cypher.internal.compiler.v3_1.planner.logical.plans.{IdName, PatternRelationship, SimplePatternLength}
import org.neo4j.cypher.internal.frontend.v3_1.ast._
import org.neo4j.cypher.internal.frontend.v3_1.{InternalException, SemanticTable, SyntaxException}
import scala.collection.mutable
object ClauseConverters {
def addToLogicalPlanInput(acc: PlannerQueryBuilder, clause: Clause): PlannerQueryBuilder = clause match {
case c: Return => addReturnToLogicalPlanInput(acc, c)
case c: Match => addMatchToLogicalPlanInput(acc, c)
case c: With => addWithToLogicalPlanInput(acc, c)
case c: Unwind => addUnwindToLogicalPlanInput(acc, c)
case c: ResolvedCall => addCallToLogicalPlanInput(acc, c)
case c: Start => addStartToLogicalPlanInput(acc, c)
case c: Create => addCreateToLogicalPlanInput(acc, c)
case c: SetClause => addSetClauseToLogicalPlanInput(acc, c)
case c: Delete => addDeleteToLogicalPlanInput(acc, c)
case c: Remove => addRemoveToLogicalPlanInput(acc, c)
case c: Merge => addMergeToLogicalPlanInput(acc, c)
case c: LoadCSV => addLoadCSVToLogicalPlanInput(acc, c)
case c: Foreach => addForeachToLogicalPlanInput(acc, c)
case x: UnresolvedCall => throw new IllegalArgumentException(s"$x is not expected here")
case x => throw new CantHandleQueryException(s"$x is not supported by the new runtime yet")
}
private def addLoadCSVToLogicalPlanInput(acc: PlannerQueryBuilder, clause: LoadCSV): PlannerQueryBuilder =
acc.withHorizon(
LoadCSVProjection(
variable = IdName.fromVariable(clause.variable),
url = clause.urlString,
format = if (clause.withHeaders) HasHeaders else NoHeaders,
clause.fieldTerminator)
).withTail(PlannerQuery.empty)
private def asSelections(optWhere: Option[Where]) = Selections(optWhere.
map(_.expression.asPredicates).
getOrElse(Set.empty))
private def asQueryShuffle(optOrderBy: Option[OrderBy]) = {
val sortItems: Seq[SortItem] = optOrderBy.fold(Seq.empty[SortItem])(_.sortItems)
QueryShuffle(sortItems, None, None)
}
private def asQueryProjection(distinct: Boolean, items: Seq[ReturnItem]): QueryProjection = {
val (aggregatingItems: Seq[ReturnItem], groupingKeys: Seq[ReturnItem]) =
items.partition(item => IsAggregate(item.expression))
def turnIntoMap(x: Seq[ReturnItem]) = x.map(e => e.name -> e.expression).toMap
val projectionMap = turnIntoMap(groupingKeys)
val aggregationsMap = turnIntoMap(aggregatingItems)
if (projectionMap.values.exists(containsAggregate))
throw new InternalException("Grouping keys contains aggregation. AST has not been rewritten?")
if (aggregationsMap.nonEmpty || distinct)
AggregatingQueryProjection(groupingKeys = projectionMap, aggregationExpressions = aggregationsMap)
else
RegularQueryProjection(projections = projectionMap)
}
private def addReturnToLogicalPlanInput(acc: PlannerQueryBuilder,
clause: Return): PlannerQueryBuilder = clause match {
case Return(distinct, ri, optOrderBy, skip, limit) if !ri.includeExisting =>
val shuffle = asQueryShuffle(optOrderBy).
withSkip(skip).
withLimit(limit)
val projection = asQueryProjection(distinct, ri.items).
withShuffle(shuffle)
val returns = ri.items.collect {
case AliasedReturnItem(_, variable) => IdName.fromVariable(variable)
}
acc.
withHorizon(projection).
withReturns(returns)
case _ =>
throw new InternalException("AST needs to be rewritten before it can be used for planning. Got: " + clause)
}
private def addSetClauseToLogicalPlanInput(acc: PlannerQueryBuilder, clause: SetClause): PlannerQueryBuilder =
clause.items.foldLeft(acc) {
case (builder, item) =>
builder.amendQueryGraph(_.addMutatingPatterns(toSetPattern(acc.semanticTable)(item)))
}
private def addCreateToLogicalPlanInput(builder: PlannerQueryBuilder, clause: Create): PlannerQueryBuilder =
clause.pattern.patternParts.foldLeft(builder) {
//CREATE (n :L1:L2 {prop: 42})
case (acc, EveryPath(NodePattern(Some(id), labels, props))) =>
acc
.amendQueryGraph(_.addMutatingPatterns(CreateNodePattern(IdName.fromVariable(id), labels, props)))
//CREATE (n)-[r: R]->(m)
case (acc, EveryPath(pattern: RelationshipChain)) =>
val (nodes, rels) = allCreatePatterns(pattern)
//remove duplicates from loops, (a:L)-[:ER1]->(a)
val dedupedNodes = dedup(nodes)
val seenPatternNodes = acc.allSeenPatternNodes
//create nodes that are not already matched or created
val nodesToCreate = dedupedNodes.filterNot(pattern => seenPatternNodes(pattern.nodeName))
//we must check that we are not trying to set a pattern or label on any already created nodes
val nodesCreatedBefore = dedupedNodes.filter(pattern => seenPatternNodes(pattern.nodeName))
nodesCreatedBefore.collectFirst {
case c if c.labels.nonEmpty || c.properties.nonEmpty =>
throw new SyntaxException(
s"Can't create node `${c.nodeName.name}` with labels or properties here. The variable is already declared in this context")
}
acc
.amendQueryGraph(_.addMutatingPatterns(nodesToCreate ++ rels: _*))
case _ => throw new CantHandleQueryException(s"$clause is not yet supported")
}
private def dedup(nodePatterns: Vector[CreateNodePattern]) = {
val seen = mutable.Set.empty[IdName]
val result = mutable.ListBuffer.empty[CreateNodePattern]
nodePatterns.foreach { pattern =>
if (!seen(pattern.nodeName)) result.append(pattern)
else if (pattern.labels.nonEmpty || pattern.properties.nonEmpty) {
//reused patterns must be pure variable
throw new SyntaxException(s"Can't create node `${pattern.nodeName.name}` with labels or properties here. The variable is already declared in this context")
}
seen.add(pattern.nodeName)
}
result.toVector
}
private def allCreatePatterns(element: PatternElement): (Vector[CreateNodePattern], Vector[CreateRelationshipPattern]) = element match {
case NodePattern(None, _, _) => throw new InternalException("All nodes must be named at this instance")
//CREATE ()
case NodePattern(Some(variable), labels, props) =>
(Vector(CreateNodePattern(IdName.fromVariable(variable), labels, props)), Vector.empty)
//CREATE ()-[:R]->()
case RelationshipChain(leftNode: NodePattern, rel, rightNode) =>
val leftIdName = IdName.fromVariable(leftNode.variable.get)
val rightIdName = IdName.fromVariable(rightNode.variable.get)
//Semantic checking enforces types.size == 1
val relType = rel.types.headOption.getOrElse(
throw new InternalException("Expected single relationship type"))
(Vector(
CreateNodePattern(leftIdName, leftNode.labels, leftNode.properties),
CreateNodePattern(rightIdName, rightNode.labels, rightNode.properties)
), Vector(CreateRelationshipPattern(IdName.fromVariable(rel.variable.get),
leftIdName, relType, rightIdName, rel.properties, rel.direction)))
//CREATE ()->[:R]->()-[:R]->...->()
case RelationshipChain(left, rel, rightNode) =>
val (nodes, rels) = allCreatePatterns(left)
val rightIdName = IdName.fromVariable(rightNode.variable.get)
(nodes :+
CreateNodePattern(rightIdName, rightNode.labels, rightNode.properties)
, rels :+
CreateRelationshipPattern(IdName.fromVariable(rel.variable.get), nodes.last.nodeName, rel.types.head,
rightIdName, rel.properties, rel.direction))
}
private def addDeleteToLogicalPlanInput(acc: PlannerQueryBuilder, clause: Delete): PlannerQueryBuilder = {
acc.amendQueryGraph(_.addMutatingPatterns(clause.expressions.map(DeleteExpression(_, clause.forced)): _*))
}
private def asReturnItems(current: QueryGraph, clause: ReturnItems): Seq[ReturnItem] =
if (clause.includeExisting)
QueryProjection.forIds(current.allCoveredIds) ++ clause.items
else
clause.items
private def addMatchToLogicalPlanInput(acc: PlannerQueryBuilder, clause: Match): PlannerQueryBuilder = {
val patternContent = clause.pattern.destructed
val selections = asSelections(clause.where)
if (clause.optional) {
acc.
amendQueryGraph { qg => qg.withAddedOptionalMatch(
// When adding QueryGraphs for optional matches, we always start with a new one.
// It's either all or nothing per match clause.
QueryGraph(
selections = selections,
patternNodes = patternContent.nodeIds.toSet,
patternRelationships = patternContent.rels.toSet,
hints = clause.hints.toSet,
shortestPathPatterns = patternContent.shortestPaths.toSet
))
}
} else {
acc.amendQueryGraph {
qg => qg.
addSelections(selections).
addPatternNodes(patternContent.nodeIds: _*).
addPatternRelationships(patternContent.rels).
addHints(clause.hints).
addShortestPaths(patternContent.shortestPaths: _*)
}
}
}
private def toPropertyMap(expr: Option[Expression]): Map[PropertyKeyName, Expression] = expr match {
case None => Map.empty
case Some(MapExpression(items)) => items.toMap
case e => throw new InternalException(s"Expected MapExpression, got $e")
}
private def toPropertySelection(identifier: Variable, map:Map[PropertyKeyName, Expression]): Seq[Expression] = map.map {
case (k, e) => In(Property(identifier, k)(k.position), Collection(Seq(e))(e.position))(identifier.position)
}.toSeq
private def toSetPattern(semanticTable: SemanticTable)(setItem: SetItem): SetMutatingPattern = setItem match {
case SetLabelItem(id, labels) => SetLabelPattern(IdName.fromVariable(id), labels)
case SetPropertyItem(Property(node: Variable, propertyKey), expr) if semanticTable.isNode(node) =>
SetNodePropertyPattern(IdName.fromVariable(node), propertyKey, expr)
case SetPropertyItem(Property(rel: Variable, propertyKey), expr) if semanticTable.isRelationship(rel) =>
SetRelationshipPropertyPattern(IdName.fromVariable(rel), propertyKey, expr)
case SetPropertyItem(Property(entityExpr, propertyKey), expr) =>
SetPropertyPattern(entityExpr, propertyKey, expr)
case SetExactPropertiesFromMapItem(node, expression) if semanticTable.isNode(node) =>
SetNodePropertiesFromMapPattern(IdName.fromVariable(node), expression, removeOtherProps = true)
case SetExactPropertiesFromMapItem(rel, expression) if semanticTable.isRelationship(rel) =>
SetRelationshipPropertiesFromMapPattern(IdName.fromVariable(rel), expression, removeOtherProps = true)
case SetIncludingPropertiesFromMapItem(node, expression) if semanticTable.isNode(node) =>
SetNodePropertiesFromMapPattern(IdName.fromVariable(node), expression, removeOtherProps = false)
case SetIncludingPropertiesFromMapItem(rel, expression) if semanticTable.isRelationship(rel) =>
SetRelationshipPropertiesFromMapPattern(IdName.fromVariable(rel), expression, removeOtherProps = false)
}
private def addMergeToLogicalPlanInput(builder: PlannerQueryBuilder, clause: Merge): PlannerQueryBuilder = {
val onCreate = clause.actions.collect {
case OnCreate(setClause) => setClause.items.map(toSetPattern(builder.semanticTable))
}.flatten
val onMatch = clause.actions.collect {
case OnMatch(setClause) => setClause.items.map(toSetPattern(builder.semanticTable))
}.flatten
clause.pattern.patternParts.foldLeft(builder) {
//MERGE (n :L1:L2 {prop: 42})
case (acc, EveryPath(NodePattern(Some(id), labels, props))) =>
val currentlyAvailableVariables = builder.currentlyAvailableVariables
val labelPredicates = labels.map(l => HasLabels(id, Seq(l))(id.position))
val propertyPredicates = toPropertySelection(id, toPropertyMap(props))
val createNodePattern = CreateNodePattern(IdName.fromVariable(id), labels, props)
val matchGraph = QueryGraph(
patternNodes = Set(IdName.fromVariable(id)),
selections = Selections.from(labelPredicates ++ propertyPredicates: _*),
argumentIds = currentlyAvailableVariables
)
val queryGraph = QueryGraph.empty
.withArgumentIds(matchGraph.argumentIds)
.addMutatingPatterns(MergeNodePattern(createNodePattern, matchGraph, onCreate, onMatch))
acc
.withHorizon(PassthroughAllHorizon())
.withTail(RegularPlannerQuery(queryGraph = queryGraph))
.withHorizon(asQueryProjection(distinct = false, QueryProjection.forIds(queryGraph.allCoveredIds)))
.withTail(RegularPlannerQuery())
//MERGE (n)-[r: R]->(m)
case (acc, EveryPath(pattern: RelationshipChain)) =>
val (nodes, rels) = allCreatePatterns(pattern)
//remove duplicates from loops, (a:L)-[:ER1]->(a)
val dedupedNodes = dedup(nodes)
val seenPatternNodes = acc.allSeenPatternNodes
//create nodes that are not already matched or created
val nodesToCreate = dedupedNodes.filterNot(pattern => seenPatternNodes(pattern.nodeName))
//we must check that we are not trying to set a pattern or label on any already created nodes
val nodesCreatedBefore = dedupedNodes.filter(pattern => seenPatternNodes(pattern.nodeName)).toSet
nodesCreatedBefore.collectFirst {
case c if c.labels.nonEmpty || c.properties.nonEmpty =>
throw new SyntaxException(
s"Can't create node `${c.nodeName.name}` with labels or properties here. The variable is already declared in this context")
}
val pos = pattern.position
val hasLabels = nodes.flatMap(n =>
n.labels.map(l => HasLabels(Variable(n.nodeName.name)(pos), Seq(l))(pos))
)
val hasProps = nodes.flatMap(n =>
toPropertySelection(Variable(n.nodeName.name)(pos), toPropertyMap(n.properties))
) ++ rels.flatMap(n =>
toPropertySelection(Variable(n.relName.name)(pos), toPropertyMap(n.properties)))
val matchGraph = QueryGraph(
patternNodes = nodes.map(_.nodeName).toSet,
patternRelationships = rels.map(r => PatternRelationship(r.relName, (r.leftNode, r.rightNode),
r.direction, Seq(r.relType), SimplePatternLength)).toSet,
selections = Selections.from(hasLabels ++ hasProps:_*),
argumentIds = builder.currentlyAvailableVariables ++ nodesCreatedBefore.map(_.nodeName)
)
val queryGraph = QueryGraph.empty
.withArgumentIds(matchGraph.argumentIds)
.addMutatingPatterns(MergeRelationshipPattern(nodesToCreate, rels, matchGraph, onCreate, onMatch))
acc.
withHorizon(PassthroughAllHorizon()).
withTail(RegularPlannerQuery(queryGraph = queryGraph)).
withHorizon(asQueryProjection(distinct = false, QueryProjection.forIds(queryGraph.allCoveredIds))).
withTail(RegularPlannerQuery())
case _ => throw new CantHandleQueryException("not supported yet")
}
}
private def addWithToLogicalPlanInput(builder: PlannerQueryBuilder,
clause: With): PlannerQueryBuilder = clause match {
/*
When encountering a WITH that is not an event horizon, and we have no optional matches in the current QueryGraph,
we simply continue building on the current PlannerQuery. Our ASTRewriters rewrite queries in such a way that
a lot of queries have these WITH clauses.
Handles: ... WITH * [WHERE <predicate>] ...
*/
case With(false, ri, None, None, None, where)
if !(builder.currentQueryGraph.hasOptionalPatterns || builder.currentQueryGraph.containsUpdates)
&& ri.items.forall(item => !containsAggregate(item.expression))
&& ri.items.forall {
case item: AliasedReturnItem => item.expression == item.variable
case x => throw new InternalException("This should have been rewritten to an AliasedReturnItem.")
} && builder.readOnly =>
val selections = asSelections(where)
builder.
amendQueryGraph(_.addSelections(selections))
/*
When encountering a WITH that is an event horizon, we introduce the horizon and start a new empty QueryGraph.
Handles all other WITH clauses
*/
case With(distinct, projection, orderBy, skip, limit, where) =>
val selections = asSelections(where)
val returnItems = asReturnItems(builder.currentQueryGraph, projection)
val shuffle =
asQueryShuffle(orderBy).
withLimit(limit).
withSkip(skip)
val queryProjection =
asQueryProjection(distinct, returnItems).
withShuffle(shuffle)
builder.
withHorizon(queryProjection).
withTail(RegularPlannerQuery(QueryGraph(selections = selections)))
case _ =>
throw new InternalException("AST needs to be rewritten before it can be used for planning. Got: " + clause)
}
private def addUnwindToLogicalPlanInput(builder: PlannerQueryBuilder, clause: Unwind): PlannerQueryBuilder =
builder.
withHorizon(
UnwindProjection(
variable = IdName(clause.variable.name),
exp = clause.expression)
).
withTail(PlannerQuery.empty)
private def addCallToLogicalPlanInput(builder: PlannerQueryBuilder, call: ResolvedCall): PlannerQueryBuilder = {
builder
.withHorizon(ProcedureCallProjection(call))
.withTail(PlannerQuery.empty)
}
private def addForeachToLogicalPlanInput(builder: PlannerQueryBuilder, clause: Foreach): PlannerQueryBuilder = {
val currentlyAvailableVariables = builder.currentlyAvailableVariables
val setOfNodeVariables =
if (builder.semanticTable.isNode(clause.variable))
Set(IdName.fromVariable(clause.variable))
else Set.empty
val foreachVariable = IdName.fromVariable(clause.variable)
val projectionToInnerUpdates = asQueryProjection(distinct = false, QueryProjection
.forIds(currentlyAvailableVariables + foreachVariable))
val innerBuilder = new PlannerQueryBuilder(PlannerQuery.empty, builder.semanticTable)
.amendQueryGraph(_.addPatternNodes((builder.allSeenPatternNodes ++ setOfNodeVariables).toSeq:_*)
.addArgumentIds(foreachVariable +: currentlyAvailableVariables.toSeq))
.withHorizon(projectionToInnerUpdates)
val innerPlannerQuery = clause.updates.foldLeft(innerBuilder) {
case (acc, innerClause) => addToLogicalPlanInput(acc, innerClause)
}.build()
val foreachPattern = ForeachPattern(
variable = IdName(clause.variable.name),
expression = clause.expression,
innerUpdates = innerPlannerQuery)
val foreachGraph = QueryGraph(
argumentIds = currentlyAvailableVariables,
mutatingPatterns = Seq(foreachPattern)
)
// Since foreach can contain reads (via inner merge) we put it in its own separate planner query
// to maintain the strict ordering of reads followed by writes within a single planner query
builder
.withHorizon(PassthroughAllHorizon())
.withTail(RegularPlannerQuery(queryGraph = foreachGraph))
.withHorizon(PassthroughAllHorizon()) // NOTE: We do not expose anything from foreach itself
.withTail(RegularPlannerQuery())
}
private def addStartToLogicalPlanInput(builder: PlannerQueryBuilder, clause: Start): PlannerQueryBuilder = {
builder.amendQueryGraph { qg =>
val items = clause.items.map {
case hints: LegacyIndexHint => Right(hints)
case item => Left(item)
}
val hints = items.collect { case Right(hint) => hint }
val nonHints = items.collect { case Left(item) => item }
if (nonHints.nonEmpty) {
// all other start queries is delegated to legacy planner
throw new CantHandleQueryException()
}
val nodeIds = hints.collect { case n: NodeHint => IdName(n.variable.name) }
val selections = asSelections(clause.where)
qg.addPatternNodes(nodeIds: _*)
.addSelections(selections)
.addHints(hints)
}
}
private def addRemoveToLogicalPlanInput(acc: PlannerQueryBuilder, clause: Remove): PlannerQueryBuilder = {
clause.items.foldLeft(acc) {
// REMOVE n:Foo
case (builder, RemoveLabelItem(variable, labelNames)) =>
builder.amendQueryGraph(_.addMutatingPatterns(RemoveLabelPattern(IdName.fromVariable(variable), labelNames)))
// REMOVE n.prop
case (builder, RemovePropertyItem(Property(variable: Variable, propertyKey))) if acc.semanticTable.isNode(variable) =>
builder.amendQueryGraph(_.addMutatingPatterns(
SetNodePropertyPattern(IdName.fromVariable(variable), propertyKey, Null()(propertyKey.position))
))
// REMOVE rel.prop
case (builder, RemovePropertyItem(Property(variable: Variable, propertyKey))) if acc.semanticTable.isRelationship(variable) =>
builder.amendQueryGraph(_.addMutatingPatterns(
SetRelationshipPropertyPattern(IdName.fromVariable(variable), propertyKey, Null()(propertyKey.position))
))
// REMOVE rel.prop when unknown whether node or rel
case (builder, RemovePropertyItem(Property(variable: Variable, propertyKey))) =>
builder.amendQueryGraph(_.addMutatingPatterns(
SetPropertyPattern(variable, propertyKey, Null()(propertyKey.position))
))
case (builder, other) =>
throw new InternalException(s"REMOVE $other not supported in cost planner yet")
}
}
}