SURF-768 Documentation for cardinality function#1574
Conversation
c8682c1 to
89d96ec
Compare
| | *Returns* 3+| `INTEGER` | ||
| |=== | ||
|
|
||
| This function was introduced as part of Cypher's xref:appendix/gql-conformance/index.adoc[] (optional GQL feature GF12, "CARDINALITY function"). |
There was a problem hiding this comment.
Not sure if this is needed, it offers new functionality unlike the alias ones you did, maybe Jens has an opinon on that though
There was a problem hiding this comment.
Agreed - this is not necessary here.
| - For a `LIST<ANY>`, `cardinality()` returns the same result as xref:functions/scalar.adoc#functions-size[`size()`]. | ||
| - For a `MAP`, it returns the same result as `size(keys(map))`. |
There was a problem hiding this comment.
Can you switch the order to match the description?
| - For a `PATH`, it returns the total number of nodes and relationships in the path. | ||
| - For a non-empty path, `cardinality(p) = 2 * length(p) + 1`. | ||
|
|
||
| Binding table reference values are not supported in Cypher, so this is an intentional subset of the full GQL cardinality expression. |
There was a problem hiding this comment.
This is not relevant here, it is most likely confusing to users who don't know GQL well
|
|
||
| | `cardinality(null)` returns `null`. | ||
| | For a `LIST<ANY>`, only top-level elements are counted; nested lists count as a single element. | ||
| | `cardinality()` on values other than a `LIST<ANY>`, `MAP`, `PATH`, or `null` will fail the query. |
There was a problem hiding this comment.
This is true of all functions, I don't think we normally say that
| RETURN cardinality([1, 2, 3]); | ||
| MATCH p = (a)-[r]->(b) RETURN cardinality(p), length(p); |
There was a problem hiding this comment.
You're missing the map case, also remove length as it isn't relevant here.
Co-authored-by: Gem Lamont <106068376+gem-neo4j@users.noreply.github.com>
Co-authored-by: Gem Lamont <106068376+gem-neo4j@users.noreply.github.com>
Co-authored-by: Jens Pryce-Åklundh <112686610+JPryce-Aklundh@users.noreply.github.com>
|
This PR includes documentation updates Updated pages: |
https://linear.app/neo4j/issue/SURF-768/gql-compliance-cardinality-function