openCypher icon indicating copy to clipboard operation
openCypher copied to clipboard

Pattern comprehension in UNWIND clause

Open JanekPo opened this issue 7 years ago • 5 comments

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

JanekPo avatar Jan 25 '18 17:01 JanekPo

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.

Mats-SX avatar Jan 29 '18 12:01 Mats-SX

@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 avatar Feb 06 '18 15:02 Lojjs

@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.

JanekPo avatar Feb 06 '18 20:02 JanekPo

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

Lojjs avatar Feb 09 '18 09:02 Lojjs

I propose we keep this issue open until we have TCK coverage for UNWIND on lists produced by list comprehensions.

Mats-SX avatar Feb 09 '18 12:02 Mats-SX