Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MatchPipe now removes parts that might conflict with other matches

  • Loading branch information...
commit fa6b5604c589b5d9e6e5bfd36d17418b7545c0bf 1 parent 945cba8
Andres Taylor authored
2  cypher/src/main/scala/org/neo4j/cypher/internal/commands/Expression.scala
View
@@ -225,7 +225,7 @@ case class Property(entity: String, property: String) extends CastableExpression
}
case class Entity(entityName: String) extends CastableExpression {
- def compute(m: Map[String, Any]): Any = m.getOrElse(entityName, throw new NotFoundException)
+ def compute(m: Map[String, Any]): Any = m.getOrElse(entityName, throw new NotFoundException("Failed to find `" + entityName + "`"))
val identifier: Identifier = Identifier(entityName, AnyType())
override def toString(): String = entityName
def declareDependencies(extectedType: AnyType): Seq[Identifier] = Seq(Identifier(entityName, extectedType))
4 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/MatchPipe.scala
View
@@ -26,10 +26,12 @@ import org.neo4j.cypher.internal.commands.{Predicate, Pattern}
class MatchPipe(source: Pipe, patterns: Seq[Pattern], predicates: Seq[Predicate]) extends Pipe {
val matchingContext = new MatchingContext(patterns, source.symbols, predicates)
val symbols = matchingContext.symbols
+ val keysToKeep = (patterns.flatMap(_.possibleStartPoints.map(_.name)) ++ predicates.flatMap(_.dependencies.map(_.name))).distinct
def createResults(state: QueryState) =
source.createResults(state).flatMap(ctx => {
- matchingContext.getMatches(ctx.toMap).map(pm => ctx.newWith( pm ) )
+ val matches = matchingContext.getMatches(ctx.filterKeys(key => keysToKeep.contains(key) || key.startsWith("-=PARAMETER=-")))
+ matches.map(pm => ctx.newWith( pm ) )
})
override def executionPlan(): String = source.executionPlan() + "\r\nPatternMatch(" + patterns.mkString(",") + ")"
10 cypher/src/test/scala/org/neo4j/cypher/ExecutionEngineTest.scala
View
@@ -2053,4 +2053,14 @@ RETURN x0.name?
val result = parseAndExecute("START a=node(1) foreach(n in extract(p in a-->() : last(p)) : set n.touched = true) return a-->()").dumpToString()
println(result)
}
+
+ @Test
+ def paths_from_match_relate_and_create() {
+ val a = createNode()
+ val b = createNode()
+ relate(a,b)
+
+ val result = parseAndExecute("START a=node(1) match p1=a-->b create p2=b-[:BACK]->a relate p3 = a-[:DOUBLE]->b return p1, p2, p3").dumpToString()
+ println(result)
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.