-
Notifications
You must be signed in to change notification settings - Fork 147
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
Map comprehensions #352
Labels
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CIR-2019-352
Motivation
There are list comprehensions:
It would also be nice to have map comprehensions, which allow the construction of maps based on key-value pairs in another map, similar to how list comprehensions allow construction of lists based on elements in another list.
Proposal
Borrowing the syntax of list comprehensions, this CIR suggests map comprehensions like the following example:
Example use cases
This could be useful to find partial property sets of entities (which may be viewed as maps with respect to their properties):
Or to remove certain properties from a set of nodes:
Or to change the name of a property key (only if considering dynamic property keys):
Open questions
Several aspects of this CIR consider making map keys dynamic (the result of evaluating an expression, rather than a direct token in the query text), which has wider consequences for the language. This proposal could be amended to only function over the values of the maps, while retaining the key for each tuple that passes the predicate.
Originally suggested in neo4j/neo4j#12152.
Since
LOAD CSV
is non-standard Cypher, the example was replaced when creating this CIR.The text was updated successfully, but these errors were encountered: