neo4j/community — Issue #256: Cypher: duplicate entries in result using optional property
Author: nawroth
Created: 2012-02-17 15:02:16+00:00
State: open
Labels: cypher

Consider:

START person=node:Person('name: *') MATCH person-->email RETURN person.name, email.address?
+------------------------------------+
| person.name | email.address? |
+------------------------------------+
| "Anakin" | "anakin@example.com" |
| "Anakin" | "anakin@example.org" |
| "Bridget" | |
| "Bridget" | |
+------------------------------------+

Bridget doesn't have an email relationship, but why two entries in the result?

I added distinct to see what happens, but then there was an NPE:
START person=node:Person('name: *') MATCH person-->email RETURN distinct person.name, email.address?
Exception in thread "main" java.lang.NullPointerException
at org.neo4j.cypher.internal.pipes.NiceHasher$$anonfun$hashCode$2.apply(NiceHasher.scala:41)
at org.neo4j.cypher.internal.pipes.NiceHasher$$anonfun$hashCode$2.apply(NiceHasher.scala:39)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194)
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
at scala.collection.immutable.List.foreach(List.scala:45)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:194)
at scala.collection.immutable.List.map(List.scala:45)
at org.neo4j.cypher.internal.pipes.NiceHasher.hashCode(NiceHasher.scala:39)
at scala.collection.mutable.HashTable$HashUtils$class.elemHashCode(HashTable.scala:366)
at scala.collection.mutable.HashMap.elemHashCode(HashMap.scala:43)
at scala.collection.mutable.HashTable$class.findEntry(HashTable.scala:108)
at scala.collection.mutable.HashMap.findEntry(HashMap.scala:43)
at scala.collection.mutable.HashMap.get(HashMap.scala:63)
at scala.collection.mutable.MapLike$class.getOrElseUpdate(MapLike.scala:186)
at scala.collection.mutable.HashMap.getOrElseUpdate(HashMap.scala:43)
at org.neo4j.cypher.internal.pipes.EagerAggregationPipe$$anonfun$createResults$1.apply(EagerAggregationPipe.scala:51)
at org.neo4j.cypher.internal.pipes.EagerAggregationPipe$$anonfun$createResults$1.apply(EagerAggregationPipe.scala:49)
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
at scala.collection.immutable.List.foreach(List.scala:45)
at org.neo4j.cypher.internal.pipes.EagerAggregationPipe.createResults(EagerAggregationPipe.scala:49)
at org.neo4j.cypher.internal.pipes.ColumnFilterPipe.createResults(ColumnFilterPipe.scala:33)
at org.neo4j.cypher.internal.ExecutionPlanImpl$$anonfun$6.apply(ExecutionPlanImpl.scala:121)
at org.neo4j.cypher.internal.ExecutionPlanImpl$$anonfun$6.apply(ExecutionPlanImpl.scala:119)
at org.neo4j.cypher.internal.ExecutionPlanImpl.execute(ExecutionPlanImpl.scala:35)
at org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:54)
at org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:51)
at org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:63)
at org.neo4j.examples.CypherSql.executeCypher(CypherSql.java:399)
at org.neo4j.examples.CypherSql.run(CypherSql.java:387)
at org.neo4j.examples.CypherSql.main(CypherSql.java:68)

My code is in here:
https://github.com/nawroth/community/blob/cyphersql/embedded-examples/src/main/java/org/neo4j/examples/CypherSql.java