-
Notifications
You must be signed in to change notification settings - Fork 60
NEXT documentation #1273
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
base: cypher-25
Are you sure you want to change the base?
NEXT documentation #1273
Conversation
This PR includes documentation updates New pages: Updated pages: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work Richard! I added som thought and edits, some which we talked about during the meeting, some that I came up with now.
@@ -188,6 +189,13 @@ For example, GQL’s graph reference values `CURRENT_GRAPH` and `CURRENT_PROPERT | |||
| xref:clauses/limit.adoc[`LIMIT`], xref:clauses/order-by.adoc[`ORDER BY`] | |||
| Cypher requires using the xref:clauses/with.adoc[`WITH`] clause, which GQL does not. | |||
|
|||
| GQ20 | |||
| `NEXT` statement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| `NEXT` statement | |
| Advanced linear composition with NEXT |
| The GQL standard includes a `YIELD` clause for its `NEXT` statement. | ||
The purpose of this `YIELD` clause is to ensure compatible behavior with SQL as it uses double quotes for delimiting identifiers. | ||
Cypher on the other hand uses double quotes for strings and backticks for quoting and thus having a `YIELD` clause does not provide additional use in Cypher. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| The GQL standard includes a `YIELD` clause for its `NEXT` statement. | |
The purpose of this `YIELD` clause is to ensure compatible behavior with SQL as it uses double quotes for delimiting identifiers. | |
Cypher on the other hand uses double quotes for strings and backticks for quoting and thus having a `YIELD` clause does not provide additional use in Cypher. | |
| The GQL standard includes a `YIELD` clause for its `NEXT` statement which Cypher does not implement. |
| Introduction of `NEXT` which allows for linear composition of queries into a sequence. | ||
For more information, see xref:queries/composed-queries/sequential-queries.adoc[]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Introduction of `NEXT` which allows for linear composition of queries into a sequence. | |
For more information, see xref:queries/composed-queries/sequential-queries.adoc[]. | |
| New `NEXT` keyword used for linear composition of queries. | |
For more information, see xref:queries/composed-queries/sequential-queries.adoc[]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The examples below seem to link the pahe in the keyword name.
== Interactions with `CALL` subqueries and `WITH` | ||
|
||
You can use `NEXT` to rewrite queries containing `CALL` subqueries or a `WITH` clause. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to what makes most sense to present. The above simple examples show in my mind the same thing as what we want to show with the WITH
part in this section. I think it could be better to remove WITH
from this section. If we want a with case we need an example where the readability greatly improves by using NEXT
. That's my thoughts at least.
== Interactions with `CALL` subqueries and `WITH` | |
You can use `NEXT` to rewrite queries containing `CALL` subqueries or a `WITH` clause. | |
== Interactions with `CALL` subqueries | |
You can use `NEXT` to rewrite queries containing `CALL` subqueries. |
[[with-rewrite]] | ||
.Rewriting a `WITH` query | ||
==== | ||
[cols="1,1"] | ||
|=== | ||
a| | ||
.`WITH` | ||
[source, cypher] | ||
---- | ||
LET a = 1 | ||
WITH a | ||
LET b = a + 1 | ||
WITH a, b | ||
LET c = a + b + 1 | ||
WITH b, c | ||
LET d = b + c | ||
RETURN d | ||
---- | ||
a| | ||
.`NEXT` | ||
[source, cypher] | ||
---- | ||
LET a = 1 | ||
RETURN a | ||
|
||
NEXT | ||
|
||
LET b = a + 1 | ||
RETURN a, b | ||
|
||
NEXT | ||
|
||
LET c = a + b + 1 | ||
RETURN b, c | ||
|
||
NEXT | ||
|
||
LET d = b + c | ||
RETURN d | ||
---- | ||
|=== | ||
==== | ||
|
||
|
||
Variables which are local to a query and which are not explicitly returned are not accessible by subsequent queries in the context of `NEXT`. | ||
This allows you to control variable scope similarly to what you can do with `WITH`, see xref:clauses/with.adoc#variable-scope[Control variables in scope]: in <<with-rewrite>>, each occurrence of `WITH` is replaced by a `RETURN` and a `NEXT`, preserving the variable scope. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[[with-rewrite]] | |
.Rewriting a `WITH` query | |
==== | |
[cols="1,1"] | |
|=== | |
a| | |
.`WITH` | |
[source, cypher] | |
---- | |
LET a = 1 | |
WITH a | |
LET b = a + 1 | |
WITH a, b | |
LET c = a + b + 1 | |
WITH b, c | |
LET d = b + c | |
RETURN d | |
---- | |
a| | |
.`NEXT` | |
[source, cypher] | |
---- | |
LET a = 1 | |
RETURN a | |
NEXT | |
LET b = a + 1 | |
RETURN a, b | |
NEXT | |
LET c = a + b + 1 | |
RETURN b, c | |
NEXT | |
LET d = b + c | |
RETURN d | |
---- | |
|=== | |
==== | |
Variables which are local to a query and which are not explicitly returned are not accessible by subsequent queries in the context of `NEXT`. | |
This allows you to control variable scope similarly to what you can do with `WITH`, see xref:clauses/with.adoc#variable-scope[Control variables in scope]: in <<with-rewrite>>, each occurrence of `WITH` is replaced by a `RETURN` and a `NEXT`, preserving the variable scope. | |
Variables which are local to a query and which are not explicitly returned are not accessible by subsequent queries in the context of `NEXT`. This allows you to control variable scope similarly to what you can do with `WITH`, see xref:clauses/with.adoc#variable-scope[Control variables in scope]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above reasoning.
==== | ||
|
||
|
||
== Interactions with conditional queries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really like this example!
== Interactions with conditional queries | ||
|
||
[[next-and-conditional]] | ||
.`NEXT` in a conditional query |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.`NEXT` in a conditional query | |
. Conditional queries in `NEXT` |
[[next-and-union]] | ||
.`NEXT` in a query using `UNION` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this example is fine and easy to reason about, maybe not the most exciting creation ever but it does the job.
No description provided.