Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-11-2020 06:22 AM
Hi,
I ask a question because I got curious while reading the manual.
The difference between functions and procedures in apoc is confusing.
CALL
clause and YIELD
their result columns================================
According to those manual, functions in neo4j return only one value, and the cardinality of the main query cannot be increased.
But there is a function(not a procedure) that returns multiple results. allshortestPaths
https://neo4j.com/docs/cypher-manual/current/clauses/match/#all-shortest-paths
What's going on here? Is this just one exception?
It may seem like nothing, but it's a big problem for me that the cardinality of the set can change, so I want to hear the exact answer to this.
Thanks
Solved! Go to Solution.
06-11-2020 11:16 AM
I agree, the distinction is fairly vague. Pretty much everything you can do with a procedure, you can do with a function. The only real difference is how they can (or are intended to) be used.
Returns a single value, which may be a Map, List, String, or Number. Note, any of these data-types could be SET
on a node property.
Returns a List (of Nodes, Maps, etc.) that is immediately unwound. Note, a List of nodes, or maps, or lists, could not be SET
on a node property.
The distinction really is in convenience of using them in Cypher. Functions can be thrown around pretty much anywhere -- SET a.newval = function(a.oldval, c.otherval)
-- while procedures usually provide data to be operated on.
06-11-2020 11:16 AM
I agree, the distinction is fairly vague. Pretty much everything you can do with a procedure, you can do with a function. The only real difference is how they can (or are intended to) be used.
Returns a single value, which may be a Map, List, String, or Number. Note, any of these data-types could be SET
on a node property.
Returns a List (of Nodes, Maps, etc.) that is immediately unwound. Note, a List of nodes, or maps, or lists, could not be SET
on a node property.
The distinction really is in convenience of using them in Cypher. Functions can be thrown around pretty much anywhere -- SET a.newval = function(a.oldval, c.otherval)
-- while procedures usually provide data to be operated on.
All the sessions of the conference are now available online