Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
🟡 Changes recommended
An active documentation issue remains because the restriction around chaining distinct() and count() is ambiguous and contradicts nearby guidance.
1 open issue
What changed in this PR
Documents ZQL aggregate, distinct(), and groupBy() query capabilities, along with regenerated search metadata.
Changes:
- Adds aggregate documentation for queries and relationships, including result semantics, synchronization, supported types, and mutation timing.
- Documents
distinct()andgroupBy()behavior, examples, limitations, null handling, ordering, and update behavior. - Regenerates the search index with the new sections and updated identifiers.
| File | Description |
|---|---|
| contents/docs/zql.mdx | Adds documentation for ZQL aggregates, distinct(), and groupBy(), including examples, semantics, limitations, and synchronization behavior. |
| assets/search-index.json | Indexes the new ZQL documentation sections and updates subsequent section identifiers. |
Review effort: Lite
|
|
||
| The aggregates work as they do without `groupBy()`, and a group whose values are all `null` gets `null` from `sum()`, `avg()`, `min()`, and `max()`. As with `distinct()`, rows with a `null` value form a group of their own, and the rows can only be ordered by the grouped columns. Ordering groups by their aggregate, such as the creators with the most issues first, isn't supported yet. | ||
|
|
||
| Neither `distinct()` nor `groupBy()` can be combined with `limit()`, `start()`, `one()`, `related()`, or another aggregate yet, and neither can group by a JSON column. They can't be used inside `related()` or `whereExists()` either, so counting each issue's distinct commenters isn't possible yet. As with other aggregates, a query defined with `defineQuery()` has to include them in its definition. |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Do not merge before Zero 1.12 is released. Aggregates,
distinct()andgroupBy()are not in a released Zero version yet. Keep this a draft until then.Re-lands #328, which merged too early and was reverted in #331. The change to
contents/docs/zql.mdxis identical to #328.Adds an Aggregates section to the ZQL page covering
count(),sum(),avg(),min(), andmax()on queries and relationships:where(),start(), andlimit()apply before the aggregate, as in SQL.0forcount(),nullotherwise), and which aggregates update immediately when a mutator runs.It also adds Distinct and Group By subsections, for
distinct()andgroupBy(...).count()/sum()/avg()/min()/max():distinct()returns one row per combination of its columns, anddistinct().count()counts them, withnullcounted as a value, unlike SQL'sCOUNT(DISTINCT).groupBy()returns one row per group with the aggregate under the function's name.nullforms a group, and rows are ordered by the grouped columns only.limit(),start(),one(),related(), a further aggregate, use inrelated()/whereExists(), JSON group columns, and ordering by the aggregate.Also regenerates
assets/search-index.json. It will conflict in that file with the JSON filters docs PR; whichever lands second needs the index regenerated. The roadmap and status pages still list aggregates and group-by as future work and should be updated when this merges.