Skip to content

Commit a2abbca

Browse files
committed
chore(spec): regenerate the reference and restate the changeset for the in-memory totalGroups count
Claude-Session: https://claude.ai/code/session_01JQwxbXGvw43spR79ztEvWt Co-authored-by: Claude <noreply@anthropic.com>
1 parent efd8097 commit a2abbca

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎.changeset/35194-query-dataset-total-groups.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Skills-docs: follow-up #35203
1111

1212
`QueryDatasetOutputSchema` gains an optional `totalGroups`: how many groups the selection formed before `offset` and `limit` cut them, the same name and meaning as `aggregate_records`' `totalGroups`. A client asked "how many are there" after a top-N cut can now answer it: a grouped `query_dataset` whose `limit` is below the group count answers `truncated: true` and the full count, and an answer that was not cut answers `totalGroups` equal to `rowCount`.
1313

14-
The count is the database's. The one SQL statement that groups and cuts the answer carries a window count over its groups (`COUNT(*) OVER ()`, after the `GROUP BY` and ahead of the `ORDER BY` and `LIMIT`), so it costs no second read and no group is fetched to be counted. Where no such statement ran, `totalGroups` is absent rather than computed some slower way: a grid the executor assembles from several queries (a measure with its own filter, a derived measure, `compareTo`) or orders by a display label, a query served by the engine's aggregate (a date bucket, a field-to-field filter, an external object, a driver with no raw SQL), and a SQL dialect the analytics strategy does not know. Read `totalGroups` as optional.
14+
The count never costs a read. Where the window is pushed into the one SQL statement that grouped the answer, the database counts the groups in that statement (`COUNT(*) OVER ()`, after the `GROUP BY` and ahead of the `ORDER BY` and `LIMIT`). Where the window is applied in memory, the count is the length of the grid before the window: an order by a display label (the tool's own order, used when none is sent, sorts every selected dimension, so grouping by any select or reference field brings this in; an order by measures alone does not), a grid assembled from several queries (a measure with its own filter, a derived measure, `compareTo`), and a query the engine's aggregate serves, such as a date bucket, a field-to-field filter, an external object or a driver with no raw SQL. That grid is counted only when every read that built it came back whole; a grid that a cap or row guard cut before the window answers no count.
1515

16-
Only the AI tool asks for the count. The REST dataset door, dashboards and reports run the statement they ran before.
16+
`totalGroups` is absent when: the window was pushed down and the SQL dialect is not one the analytics strategy knows, or a selected member is itself named `__os_group_count`, or the page came back empty after an `offset`; a read was served by a strategy that does not vouch for its grid, such as one a host adds, or was cut by a cap under it; or the dataset's object is missing and the answer is the empty one served for it. Read `totalGroups` as optional.
17+
18+
Only the AI tool asks for the count. The REST dataset door, dashboards and reports run the statements they ran before.

‎content/docs/references/ai/dataset-tools.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ const result = DatasetNextStepSchema.parse(data);
338338
| **sourceLine** | `string` | optional | The answer's source as one finished line, in the caller's locale: composed by the tool from `provenance` after the query ran, never typed by the model. `provenance` stays the structured source and this is the same source in words. The wording is the executor's; the schema declares the slot and fixes no text (ADR-0149 M1). Absent when the tool composed none, never an empty string |
339339
| **rowCount** | `integer` | ✅ | How many rows `rows` holds |
340340
| **truncated** | `boolean` | ✅ | `true` when more rows existed past the row cap the tool applied and were not returned |
341-
| **totalGroups** | `integer` | optional | How many groups the selection formed before `offset` and `limit` cut them: the rows the same selection answers with no window. The same name and meaning as `aggregate_records`' `totalGroups`. Counted in the database, by a window count in the one SQL statement that grouped and cut the answer, never by reading the groups. Equals `rowCount` when the answer was not cut. Absent when no such statement counted them: the answer was assembled from several queries (a measure with its own filter, a derived measure, `compareTo`) or ordered by a display label; the query ran through the engine's aggregate instead (a date bucket, a field-to-field filter, an external object, a driver with no raw SQL); the SQL dialect is not one the tool knows; a selected member is itself named `__os_group_count`; the page came back empty after an `offset`; or the dataset's object is missing and the answer is the empty one served for it |
341+
| **totalGroups** | `integer` | optional | How many groups the selection formed before `offset` and `limit` cut them: the rows the same selection answers with no window. The same name and meaning as `aggregate_records`' `totalGroups`. Never paid for with a read. Where the window is pushed into the one SQL statement that grouped the answer, the database counts the groups with a window count in that statement. Where the window is applied in memory, it is the length of the grid before the window: an order by a display label (the tool's own order when none is sent sorts every selected dimension, so any select or reference dimension brings it in; an order by measures alone does not), a grid assembled from several queries (a measure with its own filter, a derived measure, `compareTo`), and a query the engine's aggregate serves, such as a date bucket, a field-to-field filter, an external object or a driver with no raw SQL. That grid is counted only when every read that built it came back whole: a grid that any cap or row guard cut before the window answers no count. Equals `rowCount` when the answer was not cut. Absent otherwise, which is when: the window was pushed down and the SQL dialect is not one the tool knows, or a selected member is itself named `__os_group_count`, or the page came back empty after an `offset`; a read was served by a strategy that does not vouch for its grid, such as one a host adds, or was cut by a cap under it; or the dataset's object is missing and the answer is the empty one served for it |
342342
| **delegationNarrowed** | `true` | optional | Present, and `true`, when the caller acts as an agent whose authority narrows what it may read on the dataset's object; `warning` states the narrowing (ADR-0090 D10) |
343343
| **warning** | `string` | optional | The narrowing statement; present exactly when `delegationNarrowed` is |
344344

0 commit comments

Comments
 (0)