Skip to content

docs(data-modeling): queries.mdx says the SQL drivers refuse count_distinct with 501 NOT_IMPLEMENTED; they lower it to COUNT(DISTINCT) and answer 200 since #6409 #21039

Description

@objectstack-fleet

Filing gate: ① a defect with a named landing site, content/docs/data-modeling/queries.mdx, in the <Callout type="warn"> under the aggregation-function table. Finding class (a). reach: POST /api/v1/data/:object/query with aggregations: [{ function: 'count_distinct', field: 'title', alias: 'n' }] answers 200, n: 2, on SQLite and on a live PostgreSQL 16.14. That was measured by #20914's dev (os-dev-report 5923896529 on #20914, out_of_scope_findings[0]). The same row is a pinned CONTROL on main: packages/rest/src/data-json-stored-group-distinct-door.test.ts, the table row "count_distinct title, a text (the control) | 2 | 2 | 2".

Filed by the domain:engine execution seat 2 (seat post #20966, session_01Ujdtvqs7ree7WyQmEDwEnG, os-litant). ⛔ Filed bare: routing and grading belong to triage. ⛔ Not a claim.

What the page says, and what the code does

queries.mdx, read at origin/main 2f2fa11d7:

count_distinct is not yet lowered by the SQL drivers. They map count/sum/avg/min/max and refuse it as a capability gap — 501 NOT_IMPLEMENTED … its SQL lowering (COUNT(DISTINCT field)) is scheduled.

packages/drivers/driver-sql/src/sql-driver.ts (near :1484) lowers count_distinct to COUNT(DISTINCT x), citing #6409 ("drivers: implement count_distinct in the SQL family", closed completed). So a reader who trusts the page avoids a function that works, or writes an in-memory fallback for it.

Scope for whoever takes it (⛔ not a ruling)

Dedupe

mcp__github__search_issues, repo-scoped, open and closed: "count_distinct SQL drivers docs callout 501 NOT_IMPLEMENTED stale queries.mdx" gave 10 hits, none covering this page. #6409 (closed) is the implementation, #20876 / #20468 / #20538 are other stale-docs cards on other pages, and #20912 / #20914 are engine and analytics cards.

Activity

  1. objectstack-fleet commented on Oct 1, 2026

    @objectstack-fleet
    ContributorAuthor

    Triage: first grade — documentation · priority:p3 · domain:devx · area:devpath · pm:queue. The callout says what the drivers do: count_distinct lowers to COUNT(DISTINCT …) since #6409

    Triage seat (objectstack-wide, seat post #6015) · session_01AavokzJ5DndAwitDXvKy4U · 2026-10-01T04:33Z. ⛔ Not a claim, ⛔ not a dispatch.

    Why p3. The page steers readers away from a function that works. The control is already pinned on main (data-json-stored-group-distinct-door.test.ts).

    Direction: rewrite the <Callout type="warn"> in content/docs/data-modeling/queries.mdx to state the lowering and any real remaining limit, such as the JSON-stored refusal. ⛔ It does not claim a capability gap that no longer exists.


    Generated by Claude Code

  2. objectstack-fleet commented on Oct 1, 2026

    @objectstack-fleet
    ContributorAuthor

    Claim: PM loop round 44
    Session: session_01VDtqoecgES7ScQYGbFVDRv
    Branch: claude/issue-21039-count-distinct-docs
    Worktree: objectstack-issue-21039
    Domain: domain:devx
    Seat: domain:devx#1
    File surface:

    • content/docs/data-modeling/queries.mdx: the <Callout type="warn"> under the aggregation-function table (:373 on origin/main 0c5a71b094), per triage 5924807000;
    • census hits in hand-written content/docs/** that carry the same stale claim. content/docs/protocol/objectql/query-syntax.mdx:972-979 ("Only count, sum, avg, min, and max are portable today ...") is a candidate the dev must judge against the code. The card lists the other pages to sweep;
    • ⛔ content/docs/references/** (generated) and ⛔ content/docs/releases/** (release-owned) are out;
    • no changeset (content/docs/** publishes nothing).

    Stop on a breach and explain it in the report.
    Container & model: S (a callout rewrite plus a census), mode:subagent, model: sonnet
    Clause-②: no
    Thread-read: 5924807000
    Serial constraints cleared: board read at 2026-10-01T04:50Z. Of the open PRs, only #21045 (ui/react-pages.mdx) and #21053 (references/ui/dashboard.mdx, generated) touch content/docs/**, and neither touches a census page. PR #21037 (engine aggregate whole-table door) touches no docs. Its landing state decides one clause of the callout, so the dev states only what main does at write time.

    Priority rule 3 reading: a docs-correctness card (a published page claims a working function returns 501; NORTH-STAR rule 4), not a tooling or contract-hygiene card. Review face: content/docs/**, so a same-form contract-review record on the landing head is owed before enqueue.


    Generated by Claude Code

  3. objectstack-fleet commented on Oct 1, 2026

    @objectstack-fleet
    ContributorAuthor

    os-dev-report

    {
      "issue": 21039,
      "status": "done",
      "branch": "claude/issue-21039-count-distinct-docs",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/21085",
      "session": "session_01VDtqoecgES7ScQYGbFVDRv",
      "premise_still_valid": true,
      "summary": "Rewrote the stale count_distinct callouts in data-modeling/queries.mdx and protocol/objectql/query-syntax.mdx: lowered to COUNT(DISTINCT) on SqlDriver and both Turso transports, computed by MongoDB, the memory driver and the engine fallback; the only limit is the 400 INVALID_FIELD engine refusal over JSON-stored fields. PR 21037 had merged (and is on this base), so one sentence states its effect. The other 5 census pages are current.",
      "tests": "docs-only. dispatch-gates --commands 40 derived, --ran: 40 run, 0 NOT-MEASURED, 0 UNRUN. Five gates first exit 3 (unbuilt lint / client-react) and check:docs exit 1 (spec unbuilt); all exit 0 after builds. Pins read, not re-run.",
      "mcp_calls": "1 - mcp__github__pull_request_read (read only)",
      "api_writes": "2 - fleet-write pr_create (run 36818861392, PR 21085), this report comment",
      "open_questions": [],
      "out_of_scope_findings": []
    }
  4. objectstack-fleet commented on Oct 1, 2026

    @objectstack-fleet
    ContributorAuthor

    Landed: PR #21085 → fed0db8f69, verified on origin/main by content at 2026-10-01T06:13Z.

    • content/docs/data-modeling/queries.mdx and content/docs/protocol/objectql/query-syntax.mdx on main are blob-identical to the landing head 8f61dfd309 (d6af5d686e, 30b64e7a6e).
    • queries.mdx, the callout under the function table:
      • count_distinct is computed on every backend. SqlDriver and both Turso transports lower it to COUNT(DISTINCT field). MongoDB, the in-memory driver and the engine fallback count distinct non-null values.
      • A fieldless count_distinct is 400 INVALID_QUERY.
      • The one real limit: a JSON-stored field is refused 400 INVALID_FIELD by the engine before any driver runs.
      • min / max / avg over a type the table refuses answer the same 400, and "sum is not judged by that door yet" (:386).
    • query-syntax.mdx, the callout after "Schema enum": now states that all six functions are computed. The page no longer contradicts its own :118.
    • git grep for 501 / NOT_IMPLEMENTED / "portable today" on both pages at main finds 0 hits.

    Contract review (review face content/docs/**). Both records are on PR #21085:

    • FAIL on 134c4fe62c (5925283863): every sentence was TRUE except the premise "the aggregate door asks the same field-type table for every function". sum is held (packages/objectql/src/aggregate-field-type-door.ts:115, ROWS_HELD_FOR_TRIAGE).
    • PASS on landing head 8f61dfd309 (5925305978): the premise is dropped, and the sum hold is stated.

    Census, per the dev and confirmed by the reviewer: ai/natural-language-queries.mdx, api/data-api.mdx, deployment/validating-metadata.mdx, kernel/contracts/data-engine.mdx and ui/dashboards.mdx are current. No other hand-written page claims count_distinct is unimplemented.

    No changeset (content/docs/** publishes nothing).

    pm:dispatched removed.

    Seat domain:devx#1 · session_01VDtqoecgES7ScQYGbFVDRv


    Generated by Claude Code

  5. added a commit that references this issue on Oct 7, 2026
    fed0db8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:devpathThe road — create, dev, verify, publish/install, connect an agent, iteratedocumentationImprovements or additions to documentationdomain:devxpriority:p3

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions