Skip to content

feat(sql): add the traceroot sql schema command + docs#31

Draft
dark-sorceror wants to merge 3 commits into
feat/sql-commandfrom
feat/sql-schema-command
Draft

feat(sql): add the traceroot sql schema command + docs#31
dark-sorceror wants to merge 3 commits into
feat/sql-commandfrom
feat/sql-schema-command

Conversation

@dark-sorceror

@dark-sorceror dark-sorceror commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #28

Adds traceroot sql schema — schema introspection for the SQL Query Gateway, framed as analytical export — plus the README docs for the whole sql feature. Users can discover the curated spans / traces columns and types before writing queries, and are clearly told that input / output / metadata blobs are excluded from the analytical export.

Base branch: feat/sql-command. This PR builds on feat/sql-command, which it depends on for the sql command group and the sqlSchema() API-client method. Review/merge that PR first, or review this one against its base.

How it works

traceroot sql schema [--json]
  → GET /api/v1/public/sql/schema   (Bearer auth)
    → default: analytical-export preamble  +  aligned TABLE | COLUMN | TYPE table
      --json: { tables, note }  (raw schema + a fixed "blobs excluded" note field)

registerSqlSchema(sql) is wired into the sql group before the default query action, so traceroot sql schema resolves as a subcommand while traceroot sql "<query>" still runs the query.

What's included

sql schema subcommand (src/commands/sql/schema.ts, src/commands/sql.ts)

  • Default output: an analytical-export preamble (states input/output/metadata blobs are excluded, with a neutral reference to a possible future opt-in — no flag name promised) followed by a 3-column TABLE | COLUMN | TYPE aligned table with a bold header, consistent with traces list.
  • --json: emits the raw schema plus a top-level note field — "Analytical export schema. input/output/metadata blobs excluded from MVP." — built as an explicit object (intentionally not typed as SqlSchemaResponse).
  • Registered before the query action so subcommand dispatch wins over the default [query] argument.

Docs (README.md)

  • New "SQL — analytical export" section: the six canonical examples (count spans 24h, p95 latency by model, cost by model, export spans to CSV, find error spans, show schema) using the canonical time columns span_start_time / trace_start_time, the output-mode summary (table / --json / --csv / --output), and the blobs-excluded framing.

Test plan

  • Default output lists spans / span_id / traces / trace_id after the Analytical export schema preamble
  • --json parses to the raw schema plus the exact note field
  • Regression: input / output / metadata never appear as schema columns in either mode (asserted against the rendered table cells and the JSON column names — not a naive substring scan, since those words legitimately appear in the preamble)
  • traceroot sql schema resolves as a subcommand (not as a query string "schema"); register test covers the schema subcommand under sql
  • npm run build, npm run lint, npm run format:check clean; full Vitest suite green
  • Manual smoke against a live backend (traceroot sql schema) — not run here; no live SQL Gateway available

Summary by cubic

Adds the traceroot sql schema command for schema introspection of the analytical export and updates the README with SQL usage examples. This lets users see available tables, columns, and types before querying; input/output/metadata blobs are excluded.

  • New Features
    • traceroot sql schema: shows the analytical export schema (tables, columns, types). Blobs (input, output, metadata) are excluded.
    • Output: default preamble + TABLE | COLUMN | TYPE table; --json returns { tables, note }.
    • Registered before the default query so schema resolves as a subcommand, not a query string.
    • README: adds SQL analytical export section with common queries, output modes, and the schema command.

Written for commit f79442a. Summary will update on new commits.

Review in cubic

@dark-sorceror dark-sorceror linked an issue Jun 29, 2026 that may be closed by this pull request
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the traceroot sql schema CLI command + docs examples

1 participant