Skip to content

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

@InverseFalcon

Description

@InverseFalcon

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions