Map Projection #216
Map Projection #216
Conversation
This CIP also takes on #201. |
Good start! I'd like to see some more examples, especially on |
|
||
== Map Projection | ||
|
||
Map projection takes a map or entity (node or relationship) and creates a map based on selected properties from map or entity. |
Mats-SX
Apr 18, 2017
Member
selected properties from the
map or ...
selected properties from the
map or ...
|
||
Map projection takes a map or entity (node or relationship) and creates a map based on selected properties from map or entity. | ||
The map projection largely reuses the map syntax of curly braces and comma separated entries. | ||
But the projection entries are just a single identifier starting with a dot (.). |
Mats-SX
Apr 18, 2017
Member
I'd fuse these sentences, like
separated entries, but the projection entries
or
separated entries, with the exception that the projection entries only use a single identifier
I'd fuse these sentences, like
separated entries, but the projection entries
or
separated entries, with the exception that the projection entries only use a single identifier
{alpha: someMap.alpha, beta: someMap.beta} | ||
---- | ||
|
||
In order to be further useful, map projection allow other types of selectors to augment the projected map. |
Mats-SX
Apr 18, 2017
Member
map projections
map projections
Mats-SX
Apr 18, 2017
Member
It would be useful with an example of, or some more discussion around, these other types of selectors.
It would be useful with an example of, or some more discussion around, these other types of selectors.
Mats-SX
Apr 18, 2017
Member
Now I read about selectors further below; perhaps a cross-reference here is enough (e.g. 'read more about these in Selectors').
Now I read about selectors further below; perhaps a cross-reference here is enough (e.g. 'read more about these in Selectors').
• *Literal entry* - includes a entry into the projected map using the regular map entry syntax, i.e. with the value being explicitly different from the key. | ||
In this case the value can be any arbitrary expression, just like in a regular map literal. | ||
• *All properties selector* - includes all properties from the original map or entity into the projected map. + | ||
The all properties selector also allows marking properties for exclusion that would otherwise have been included by the selector. + |
Mats-SX
Apr 18, 2017
Member
The +
at the end of the line forces a line break; is this intended. I find that it renders unusefully.
The +
at the end of the line forces a line break; is this intended. I find that it renders unusefully.
thobe
Apr 18, 2017
Author
Contributor
Yes, that is intentional. The second sentence is specific point about all properties selectors. I thought it was worth highlighting that, so I put it on its own line, since I thought a single sub-bullet was too much weight for it.
Yes, that is intentional. The second sentence is specific point about all properties selectors. I thought it was worth highlighting that, so I put it on its own line, since I thought a single sub-bullet was too much weight for it.
In this case the value can be any arbitrary expression, just like in a regular map literal. | ||
• *All properties selector* - includes all properties from the original map or entity into the projected map. + | ||
The all properties selector also allows marking properties for exclusion that would otherwise have been included by the selector. + | ||
If any properties explicitly stated in the map projection through another selector type conflicts with a property in the original map, the explicitly stated entry takes precedence and the value from that expression overrides the value from the original map. |
Mats-SX
Apr 18, 2017
Member
I think this makes sense, but I'd like to record that we could make this kind of conflict an error, effectively forcing users to explicitly exclude conflicting entries. Perhaps that could be a configurable semantics?
I think this makes sense, but I'd like to record that we could make this kind of conflict an error, effectively forcing users to explicitly exclude conflicting entries. Perhaps that could be a configurable semantics?
thobe
Apr 18, 2017
Author
Contributor
There is a later sentence on cases where you might actually want the overriding behaviour.
There is a later sentence on cases where you might actually want the overriding behaviour.
[source, cypher] | ||
.Fetch name and address for a person | ||
---- | ||
MATCH (person:Person{userId=$user})-[:ADDRESS]->(address) |
Mats-SX
Apr 18, 2017
Member
Syntax error: should be :
instead of =
in the inlined property predicate.
Cypher style: space between the inlined label predicate and the inlined property predicate.
Syntax error: should be :
instead of =
in the inlined property predicate.
Cypher style: space between the inlined label predicate and the inlined property predicate.
| person | | ||
+----------------------------------------------------------------------------------------+ | ||
| {firstName: "Sherlock", lastName: "Holmes", id: "0099CC", | | ||
| address: {streetAddress: "221B Baker Street", city: "London", postalCode: "NW1 6XE"}} | |
Mats-SX
Apr 18, 2017
Member
Cypher style: single ticks for literal strings.
Cypher style: single ticks for literal strings.
[source, cypher] | ||
.Bind variables into a map | ||
---- | ||
MATCH (group:Group{name:$groupName})<-[:MEMBER_OF]-(member)-[:KNOWS]-(friend)-[:ADDRESS]->(address) |
Mats-SX
Apr 18, 2017
Member
Cypher style: space between label and property predicate.
Cypher style: space after :
in property predicate.
Cypher style: space between label and property predicate.
Cypher style: space after :
in property predicate.
.Bind variables into a map | ||
---- | ||
MATCH (group:Group{name:$groupName})<-[:MEMBER_OF]-(member)-[:KNOWS]-(friend)-[:ADDRESS]->(address) | ||
RETURN member.name, collect( {friend{.name},address{.city}} ) AS friends |
Mats-SX
Apr 18, 2017
Member
Cypher style: no space on insides of the collect()
parentheses.
Cypher style: space after comma.
Cypher style: no space on insides of the collect()
parentheses.
Cypher style: space after comma.
+-------------+---------------------------------------------------------------+ | ||
| Eve Longman | • {friend: {name:"Mickey Mouse"}, address:{city:"Orlando"}} | | ||
| | • {friend: {name:"Leroy Jenkins"}, address:{city:"New York"}} | | ||
| | • {friend: {name:"Minnie Mouse"}, address:{city:"Orlando"}} | |
Mats-SX
Apr 18, 2017
Member
Cypher style: single tick for literal string.
Cypher style: space after colons.
Cypher style: single tick for literal string.
Cypher style: space after colons.
Is this suposed to be implemented ? |
Solves #178.
CIP2017-02-07