-
Notifications
You must be signed in to change notification settings - Fork 62
Added section on by-table semantics #1345
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
Added section on by-table semantics #1345
Conversation
21e2903
to
9d9f338
Compare
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
@@ -383,12 +384,45 @@ RETURN customer.firstName AS plantCustomer | |||
1+d|Rows: 6 | |||
|=== | |||
|
|||
=== Leveraging by-table semantics using `UNION` after `NEXT` |
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.
=== Leveraging by-table semantics using `UNION` after `NEXT` | |
=== Leveraging by-table semantics using `UNION` after `NEXT` | |
(spacing only)
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.
This heading is the first mention of "by-table semantics". It falls out of the sky. I think, the much earlier section "Passing values to subsequent queries", which current is without change, should make clear that NEXT
passes the whole table of intermediate results to the subsequent query. Maybe even show a second example with aggregation.
On the more general level, the page currently reflects the journey we as implementor went through. But it should not — users do not care about our troubles, which meaningless to them.
The page should be present NEXT as the feature that allows to pass the whole table of intermediate result to a subsequent query.
So the effects and benefits of that should come first — instead of in the last section.
So, consider to adjust the order of the section to this:
- Passing values to subsequent queries
- Interactions with UNION queries
- Interactions with CALL subqueries
- Interactions with conditional queries
In the latter two section, it should be explicitly pointed out respectively that CALL and conditionals only pass individual rows.
The text in "Interactions with CALL subqueries" also need some adjustment. For instance "NEXT
can serve as a more readable alternative to CALL subqueries." Not sure we need to hang it this high now. Maybe it is better to show example where CALL nests NEXT and vice verse to illustrate the combined effect of their by-row and by-table semantics.
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
@@ -383,12 +384,45 @@ RETURN customer.firstName AS plantCustomer | |||
1+d|Rows: 6 | |||
|=== | |||
|
|||
=== Leveraging by-table semantics using `UNION` after `NEXT` |
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.
This heading is the first mention of "by-table semantics". It falls out of the sky. I think, the much earlier section "Passing values to subsequent queries", which current is without change, should make clear that NEXT
passes the whole table of intermediate results to the subsequent query. Maybe even show a second example with aggregation.
On the more general level, the page currently reflects the journey we as implementor went through. But it should not — users do not care about our troubles, which meaningless to them.
The page should be present NEXT as the feature that allows to pass the whole table of intermediate result to a subsequent query.
So the effects and benefits of that should come first — instead of in the last section.
So, consider to adjust the order of the section to this:
- Passing values to subsequent queries
- Interactions with UNION queries
- Interactions with CALL subqueries
- Interactions with conditional queries
In the latter two section, it should be explicitly pointed out respectively that CALL and conditionals only pass individual rows.
The text in "Interactions with CALL subqueries" also need some adjustment. For instance "NEXT
can serve as a more readable alternative to CALL subqueries." Not sure we need to hang it this high now. Maybe it is better to show example where CALL nests NEXT and vice verse to illustrate the combined effect of their by-row and by-table semantics.
@hvub @rsill-neo4j, I've done a substantial rewrite and reorganization now, trying to put by-table semantics front and center. I find it quite difficult to construct interesting examples, and should we introduce the concept of by-table, by-row semantics at all or just refer to it in more general terms? |
@rsill-neo4j I have updated the page a bit more to address my own comments on top of what @JoelBergstrand already did. @JoelBergstrand is out for vacation. I am taking over the PR, so that we can make whatever deadline for the next release is. I am done editing, so please have a look and feel free to fix any editorial sins I may have committed. 😄 |
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.
editorial suggestions
.Passing multiple variables to another query via `NEXT` | ||
// tag::sequential_queries_basic_example[] |
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.
these should probably stay (used for cypher cheat sheet includes)
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.
Ah.. okay. I didn't know that.
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 have add tags again, but on a newly made selection of three queries.
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
@rsill-neo4j What is the state of this PR from your point of view? Do you need any more input to take it over the finish line? |
….adoc Co-authored-by: Richard Sill <[email protected]>
….adoc Co-authored-by: Hannes Voigt <[email protected]>
….adoc Co-authored-by: Hannes Voigt <[email protected]>
f04dcee
to
63bdec3
Compare
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.
updated include tags
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
added a few suggestions for the tags - i'll create a PR for the cheat sheet to account for this. |
Co-authored-by: Richard Sill <[email protected]>
@rsill-neo4j, @hvub, I've rereviewed the PR, looks great! |
|
||
NEXT | ||
|
||
MATCH (c:Customer)-[:BUYS]->(p) | ||
RETURN collect(c.firstName) AS customers, p | ||
RETURN c.firstName AS name, COLLECT(p.price * c.discount) AS purchases, "discounted price" AS type |
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.
while not technically wrong, i think the discount is calculated incorrectly on a conceptual level -
shouldn't it be (1 - c.discount) ? for example, hannah's laptop is at a discounted price of 37.5 (down from 250)
stumbled upon this just now while trying to understand the testing error
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 you are right.
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.
Should be fixed.
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.
4 suggestions to make it clear that changes were introduced with 2025.08, and an entry in the additions page as a direct commit
* `NEXT` can improve the usability of xref:queries/composed-queries/conditional-queries.adoc[conditional `WHEN`] and xref:queries/composed-queries/combined-queries.adoc[combined `UNION`] queries. | ||
* `NEXT` can be used instead of xref:clauses/with.adoc[] clause to construct complex queries. | ||
* `NEXT` can improve the usability of xref:queries/composed-queries/conditional-queries.adoc[]. | ||
* `NEXT` allows for passing the full table of intermediate results into the arms of xref:queries/composed-queries/combined-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.
* `NEXT` allows for passing the full table of intermediate results into the arms of xref:queries/composed-queries/combined-queries.adoc[]. | |
* `NEXT` allows for passing the full table of intermediate results to a xref:queries/composed-queries/combined-queries.adoc[`UNION`] 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.
Maybe just: "...results to a xref:queries/composed-queries/combined-queries.adoc[
UNION`] clause". (i.e. get rid of the poetic "into the arms" 😄 )
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.
If I understand it correctly, the below sections marked as new in 2025.08 are not new to this release (e.g. you could have NEXT interact with CALL in 2025.07), and I am not understanding from this update how it impacts users? If it is just an under-the-hood update, then I think it is fine to only make a small mention of it. E.g.
"As of Neo4j 2025.08,... Previously, ...."
If this makes a meaningful change to how NEXT queries work in 2025.06 and 2025.07, then we should have an example to the effect of "NEXT used to work like this: Now it works like that:..."
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.
double-checking the queries in the old version, at least this one (NEXT inside CALL) behaves differently (yielding 100% for all products):
MATCH (p:Product) WHERE p.name <> "Coffee"
CALL (p) {
MATCH (p)<-[:BUYS]-(c:Customer)-[:BUYS]->(otherProduct)
RETURN c, otherProduct
NEXT
RETURN count(DISTINCT c) AS customers, 0 AS customersAlsoBuyingCoffee
UNION
FILTER otherProduct.name = "Coffee"
RETURN 0 as customers, count(DISTINCT c) AS customersAlsoBuyingCoffee
NEXT
RETURN max(customers) AS customers, max(customersAlsoBuyingCoffee) AS customersAlsoBuyingCoffee
}
RETURN p.name AS product,
round(toFloat(customersAlsoBuyingCoffee) * 100 / customers, 1) AS percentageOfCustomersAlsoBuyingCoffee
ORDER BY product
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.
If there is aggregation in CALL the previous implementation was wrong, so they errored in the last release. Now they are implemented correctly. In that sense it is new.
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 same for aggregation in a UNION.
| The `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.
This entry should be for allReduce
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.
copy-paste error! should be fixed
* `NEXT` can improve the usability of xref:queries/composed-queries/conditional-queries.adoc[conditional `WHEN`] and xref:queries/composed-queries/combined-queries.adoc[combined `UNION`] queries. | ||
* `NEXT` can be used instead of xref:clauses/with.adoc[] clause to construct complex queries. | ||
* `NEXT` can improve the usability of xref:queries/composed-queries/conditional-queries.adoc[]. | ||
* `NEXT` allows for passing the full table of intermediate results into the arms of xref:queries/composed-queries/combined-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.
Maybe just: "...results to a xref:queries/composed-queries/combined-queries.adoc[
UNION`] clause". (i.e. get rid of the poetic "into the arms" 😄 )
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
* `NEXT` can improve the usability of xref:queries/composed-queries/conditional-queries.adoc[conditional `WHEN`] and xref:queries/composed-queries/combined-queries.adoc[combined `UNION`] queries. | ||
* `NEXT` can be used instead of xref:clauses/with.adoc[] clause to construct complex queries. | ||
* `NEXT` can improve the usability of xref:queries/composed-queries/conditional-queries.adoc[]. | ||
* `NEXT` allows for passing the full table of intermediate results into the arms of xref:queries/composed-queries/combined-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.
If I understand it correctly, the below sections marked as new in 2025.08 are not new to this release (e.g. you could have NEXT interact with CALL in 2025.07), and I am not understanding from this update how it impacts users? If it is just an under-the-hood update, then I think it is fine to only make a small mention of it. E.g.
"As of Neo4j 2025.08,... Previously, ...."
If this makes a meaningful change to how NEXT queries work in 2025.06 and 2025.07, then we should have an example to the effect of "NEXT used to work like this: Now it works like that:..."
Co-authored-by: Jens Pryce-Åklundh <[email protected]>
…result table of an example query
… to 'branches' (UNION)
modules/ROOT/pages/queries/composed-queries/sequential-queries.adoc
Outdated
Show resolved
Hide resolved
….adoc Co-authored-by: Jens Pryce-Åklundh <[email protected]>
modules/ROOT/pages/deprecations-additions-removals-compatibility.adoc
Outdated
Show resolved
Hide resolved
Co-authored-by: Jens Pryce-Åklundh <[email protected]>
Thanks for the documentation updates. The preview documentation has now been torn down - reopening this PR will republish it. |
Adding section on by-table semantics for NEXT, removing the section on known limitations.