openCypher
openCypher copied to clipboard
Pattern comprehension in UNWIND clause
Is pattern comprehension in UNWIND clause legal?
unwind [(a)-->(b) | id(b)] as c
return c
console.neo4j.org throws:
Error: java.util.NoSuchElementException: None.get
Any expression that evaluates to a list is valid for UNWIND
. If Neo4j does not support it, that is a bug.
The UNWIND
CIP #230 suggests extending the definition, allowing any value to be a valid expression for UNWIND
by interpreting non-null non-lists as singleton lists.
@JanekPo this seems like a bug. If you can come back with which version of Neo4j you are using and if you getting the message on an empty database or not, me and my colleagues can have a look at it.
Best regards Louise, Neo4j Cypher team
@Lojjs I have executed the query in default configuration on http://console.neo4j.org. Error occurs in case of both default and empty database. I am sure this a bug, but there is no scenario in TCK for a pattern comprehension in UNWIND clause.
The console is currently using an older version of neo4j (3.1.0), but there are plans to upgrade it to 3.3. We have therefore solved the bug in a PR (https://github.com/neo4j/neo4j/pull/10991) which will be included in 3.3.4. Meanwhile, you can use this query which should be semantically equivalent
MATCH (a)-->(b)
WITH collect(id(b)) AS var
UNWIND var AS c
RETURN c
I propose we keep this issue open until we have TCK coverage for UNWIND
on lists produced by list comprehensions.