Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support calling aggregation functions on lists in expressions #183

Open
boggle opened this issue Feb 5, 2017 · 3 comments
Open

Support calling aggregation functions on lists in expressions #183

boggle opened this issue Feb 5, 2017 · 3 comments

Comments

@boggle
Copy link
Contributor

boggle commented Feb 5, 2017

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.

@boggle boggle added the CIR label Feb 5, 2017
@thobe
Copy link
Contributor

thobe commented Feb 22, 2017

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.

@thobe
Copy link
Contributor

thobe commented Apr 13, 2017

Another way to solve this is by scalar subqueries (pending syntax finalization):

RETURN  <(((< UNWIND my_list AS item RETURN sum(item) >)))>

@trzeci
Copy link

trzeci commented Jun 1, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants