Skip to content

Commit 22a2b60

Browse files
hotlongclaude
andauthored
docs(api): /analytics/query 示例的 measure 拼写改为 revenue_sum,并写明合法拼写 (#6291) (#6372)
示例里 `revenue.sum` 的首段 `revenue` 不是 cube 名(cube 是 `account`), 所以它不是 cube 名限定符。#5918(PR #6292)落地后,这条示例在运行时得到 400 INVALID_FIELD 并点名 `revenue.sum` 本身,且不执行任何查询 —— 即照 文档抄的查询跑不通。 六处同批改正(请求 + 响应两个半边,避免出现「文档化的请求与文档化的 响应 key 对不上」),并在 data-api.mdx 的 /analytics/query 段落写明合法 拼写:对象自己的字段 + 聚合后缀,或 Cube 声明的 measure 名;点号仅在 作 cube 名限定符时合法。 Claude-Session: https://claude.ai/code/session_01BDmDsu2575gDxeMCxXhDE3 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8d86f8d commit 22a2b60

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

content/docs/api/client-sdk.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ for the underlying endpoint contract.
264264
// Semantic analytics query (cube-style)
265265
const result = await client.analytics.query({
266266
cube: 'account',
267-
measures: ['revenue.sum', 'count'],
267+
measures: ['revenue_sum', 'count'],
268268
dimensions: ['industry'],
269269
where: { status: 'active' },
270270
limit: 100,
@@ -276,7 +276,7 @@ const meta = await client.analytics.meta('account');
276276
// Dry-run a query to its generated SQL (POST /analytics/sql)
277277
const explained = await client.analytics.explain({
278278
cube: 'account',
279-
measures: ['revenue.sum'],
279+
measures: ['revenue_sum'],
280280
});
281281
```
282282

content/docs/api/data-api.mdx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,28 @@ Execute an analytics query.
335335
```json
336336
{
337337
"cube": "account",
338-
"measures": ["revenue.sum", "count"],
338+
"measures": ["revenue_sum", "count"],
339339
"dimensions": ["industry"],
340340
"where": { "status": "active" },
341341
"limit": 100
342342
}
343343
```
344344

345+
<Callout type="info">
346+
**How to spell a measure.** A `measures` entry is either a measure the Cube **declares**,
347+
or one of the inferred spellings: the bare `count` (`COUNT(*)`), or one of the object's
348+
**own** field names plus an aggregation suffix — `_sum`, `_avg`, `_min`, `_max`,
349+
`_count_distinct`. So "the sum of `revenue`" is `revenue_sum`.
350+
351+
A dot is legal **only** as the `<cube>.` qualifier: `account.revenue_sum` resolves to the
352+
same measure as `revenue_sum` (the response column keeps whichever of the two you sent).
353+
Any other dotted spelling — `revenue.sum`, `owner.amount_sum` — is refused with
354+
`400 INVALID_FIELD` naming the spelling you sent, and nothing is executed: measures do not
355+
traverse relationships, only dimensions do, so there is no related column for a dotted
356+
measure to aggregate. To aggregate a related column, declare a Cube whose measure names it
357+
in its own `sql`.
358+
</Callout>
359+
345360
<Callout type="info">
346361
Filtering uses the canonical Query DSL `where` object (the same MongoDB-style `FilterCondition` accepted by `find()`), not a `filters` array.
347362
</Callout>
@@ -352,12 +367,12 @@ Filtering uses the canonical Query DSL `where` object (the same MongoDB-style `F
352367
"success": true,
353368
"data": {
354369
"rows": [
355-
{ "industry": "Technology", "revenue.sum": 150000, "count": 5 },
356-
{ "industry": "Healthcare", "revenue.sum": 80000, "count": 3 }
370+
{ "industry": "Technology", "revenue_sum": 150000, "count": 5 },
371+
{ "industry": "Healthcare", "revenue_sum": 80000, "count": 3 }
357372
],
358373
"fields": [
359374
{ "name": "industry", "type": "string", "label": "Industry" },
360-
{ "name": "revenue.sum", "type": "number", "label": "Revenue Sum", "format": "$0,0" },
375+
{ "name": "revenue_sum", "type": "number", "label": "Revenue Sum", "format": "$0,0" },
361376
{ "name": "count", "type": "number", "label": "Count" }
362377
],
363378
"sql": "SELECT ..."

0 commit comments

Comments
 (0)