Support calling aggregation functions on lists in expressions
CIR-2017-183
Cypher has a great set of aggregation functions that can be used to compute aggregate values over multiple result records.
However it currently is not possible to call these aggregation functions on lists in an expression evaluation context. Currently users that need to achieve this usually try to help themselves by using collect, UNWIND, and list comprehensions.
This CIR looks for a better way to achieve this user goal.
Requirements
Proposals should provide a syntax extensions for allowing to call aggregation functions over lists in an expression evaluation context.
If we use another syntax for aggregation [CIR2017-188], then using the aggregator name with regular function-call syntax could be used to aggregate over a list argument.
Another way to solve this is by scalar subqueries (pending syntax finalization):
RETURN <(((< UNWIND my_list AS item RETURN sum(item) >)))>
There is function reduce() having functionality suitable for min/max/sum/avg. E.g.: reduce( i=0, x IN list | i+x ) is equivalent to sum(list).