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

Allow DISTINCT, ORDER BY, LIMIT, and SKIP within pattern comprehensions #202

Open
InverseFalcon opened this issue Mar 6, 2017 · 5 comments
Labels

Comments

@InverseFalcon
Copy link

InverseFalcon commented Mar 6, 2017

CIR-2017-202

While it is possible to take a slice of the resulting list from pattern comprehension, this operation is not lazy (like LIMIT), so all results of the comprehension must be computed to form the full list, then the resulting slice is taken.

This is request for using LIMIT (or perhaps a separate keyword, if the overloaded usage is too confusing) within a pattern comprehension, which only limits the number of results within the resulting collection. It will not limit the number of rows of the query.

Here's an example of a query using this proposed feature request that gets 5 actors, and for each of those 5 actors gets 2 movies they've acted in:

MATCH (actor:Person)
WITH actor LIMIT 5
RETURN actor, [(actor)-[:ACTED_IN]->(m:Movie) | m LIMIT 2] as movies

This also requests ORDER BY and SKIP, in similar placement, before LIMIT and after the expression defining the elements for the collection.

@InverseFalcon InverseFalcon changed the title Support ORDER BY, LIMIT, and SKIP within pattern comprehensions Allow ORDER BY, LIMIT, and SKIP within pattern comprehensions Mar 6, 2017
@petraselmer petraselmer added the CIR label Mar 6, 2017
@thobe
Copy link

thobe commented Mar 6, 2017

Related to CIR-2017-190

@InverseFalcon InverseFalcon changed the title Allow ORDER BY, LIMIT, and SKIP within pattern comprehensions Allow DISTINCT, ORDER BY, LIMIT, and SKIP within pattern comprehensions Apr 26, 2017
@InverseFalcon
Copy link
Author

Supporting usage of DISTINCT would also be great, otherwise we have to rely on apoc.coll.toSet() to get the list of distinct values, which is problematic because this would happen after LIMIT, SKIP, and ORDER BY.

@thobe
Copy link

thobe commented Dec 20, 2018

Would be solved by #217

@SpaghettiFactory
Copy link

This seems like a very useful feature. Does anyone know the status on this?

@thobe
Copy link

thobe commented May 27, 2020

@SpaghettiFactory see my previous comment. This is (to be) solved by list subqueries, which is a generalisation of pattern comprehension.

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

No branches or pull requests

4 participants