Skip to content

feat(admin): make the Trino queries view readable at pool scale - #1257

Merged
fuziontech merged 1 commit into
mainfrom
feat/admin-trino-queries-view
Oct 7, 2026
Merged

fuziontech merged 1 commit into
mainfrom
feat/admin-trino-queries-view

Conversation

@fuziontech

Copy link
Copy Markdown
Member

Problem

Watching Portola's SQLMesh plan on /trino/queries?cell=cell-001 was hard:

  • The page landed empty until a cell was picked.
  • The "Queued" card said 0 while queries sat in WAITING_FOR_RESOURCES.
  • Every row started with the same /* SQLMESH_PLAN … */ comment, so you couldn't tell which model a query was building.
  • There was no way to see which tenant or pool instance was using the cell.

Changes

Cell default. TrinoCellPicker fills an absent cell parameter with the first registered cell, using replace navigation so the back button is unaffected. An explicit cell= in the URL, even an unknown one, is never replaced. This reverses the "explicit selection even with one cell" behaviour from #1171/#1246, as requested.

Waiting states. "Waiting" (formerly "Queued") counts QUEUED, WAITING_FOR_RESOURCES, DISPATCHING, PLANNING and STARTING. The same states get the queued flag and the warning badge colour.

Readable rows. trinoSqlSummary strips leading comments and extracts the verb and target, for example INSERT INTO org_x.sqlmesh_trino.events__123. The comment is kept as the "client tag". Clicking a row expands it to show the full (still redacted) SQL plus query id, principal, source, resource group, drivers, rows read, network, spill, queued time and error.

Breakdowns. There are "By org" and "By pool instance" tables showing running, waiting (with blocked), CPU, scanned, peak memory and longest query. Clicking a row filters the list. The headline cards and breakdowns follow the search box but not the drill-down filters, so they keep describing the whole cell.

Navigation.

  • State chips (All / Running / Waiting, plus Failed / Finished when finished queries are included), with counts.
  • Sortable columns: state, org, elapsed, progress, CPU, scanned, peak memory. Ties break on elapsed then query id, so rows don't jump on the 2s poll.
  • A progress bar column.
  • Search now matches SQL text and query id as well as org and principal.

Backend. admin.TrinoQuery gains instance (omitempty). trinoPoolObserver.Queries and Query stamp it with the pool instance whose coordinator holds the query. A cell with a single coordinator leaves it empty, and the UI then hides the instance column and breakdown.

Tests

  • lib/trino.test.ts: waiting states, SQL summary (SQLMesh comment, quoted identifiers, DDL kinds, WITH reads), grouping, sorting.
  • TrinoQueries.test.tsx: waiting count, verb/target rendering, expand/collapse, sorting, state chips, org drill-down and clear, instance breakdown shown or hidden, SQL and query-id search, Kill not expanding the row.
  • TrinoCellPicker.test.tsx: defaults with one cell and with several, keeps an explicit cell, no navigation before the list loads.
  • trino_pool_observer_test.go: list and detail both carry the owning instance.
  • e2e tests/mw-dev/e2e/trino.sh: the live long-running query names one of pool-test's instances in both the list and the detail.

Results: vitest 279/279, typecheck, lint (no new warnings), build, and go test -tags kubernetes ./controlplane/ -run 'TestTrinoPoolObserver|TestPooledCell'. Locally TestAdminGetOrgPreloadsTrinoPostgres needs docker-compose, which isn't installed here; it is unrelated.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Nic9bR3LPTRLk56ntJ4M5Z

- Count every pre-execution state (QUEUED, WAITING_FOR_RESOURCES,
  DISPATCHING, PLANNING, STARTING) as waiting. Only QUEUED was counted,
  so a saturated cell reported 0 queued.
- Lead each row with the statement verb and target table, with leading
  client comments (SQLMesh plan markers) stripped. Rows expand to the
  full SQL and execution detail (drivers, rows, network, spill, tag).
- Per-org and per-pool-instance breakdowns; click one to filter.
- State-bucket filter chips, sortable columns, a progress bar, and search
  over SQL text and query id as well as org and principal.
- The pool observer stamps each query (list and detail) with the instance
  whose coordinator holds it.
- The cell picker defaults to the first registered cell when the URL
  names none, instead of rendering an empty page. An explicit cell in the
  URL is never replaced.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nic9bR3LPTRLk56ntJ4M5Z
@fuziontech
fuziontech requested a review from a team October 7, 2026 14:02

@bill-ph bill-ph left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked the cell-picker defaulting (against forCell requiring an explicit cell and handleCells sorting by ID, so "first cell" is deterministic), the waiting-state and bucket logic, trinoSqlSummary (the regexes are anchored and have disjoint alternations, so there's no catastrophic backtracking on large SQLMesh statements), grouping and sorting, the new table layout (the expanded row's colSpan matches 10 or 11 columns), Kill/copy click propagation, and the Go observer and e2e changes that stamp instance. The backend change is small, and the list and detail paths are both tested.

P2

  • orgPick and instancePick (and bucket) are not reset when the cell picker changes cell. A drill-down picked on cell-001 carries over to cell-002 and usually shows an empty list. The Clear chip does appear, though.
  • Rows expand only on a mouse click on the <tr>, so keyboard users can't reach the full SQL or details. Also, aria-sort is set on the <button>, but it is only valid on the column header (TableHead/th).
  • The defaulting also applies on TrinoCluster (it shares TrinoCellPicker), so that page now lands on cell-001 with its recovery controls. That's probably intended, but the PR description only mentions the queries page.

Inline comments

  • controlplane/admin/ui/src/pages/TrinoQueries.tsx:258 — P2: orgPick/instancePick (and bucket) survive a cell switch from TrinoCellPicker, so a drill-down from one cell silently filters the next cell's list, usually to empty. Consider resetting them when cell changes, e.g. key the page state on cell.
  • controlplane/admin/ui/src/pages/TrinoQueries.tsx:489 — P2: Expansion is mouse-only (an onClick on the tr, with no focusable control and no aria-expanded). Making the chevron cell a <button aria-expanded> would make it keyboard-accessible. Separately, aria-sort at line 147 belongs on the TableHead, not on the inner button.

— Robo Bill v2 (opus, high reasoning)

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

Test Impact Plan

Deterministic summary of how this PR changes tests, CI runners, and coverage-risk signals.

Summary

Area Added Changed Deleted
Test files 0 2 0
E2E/journey files 0 0 0
Workflow files 0 0 0

Signals

  • Test cases: +1 / -0
  • Assertions: +4 / -0
  • Skips or known failures added: 0
  • Workflow continue-on-error added: 0
  • Workflow path filters added: 0
  • Test commands removed from justfile: 0
  • E2E/journey retry lines added: 0

Coverage risk: neutral or increased

No coverage-reduction warnings detected.

@fuziontech
fuziontech merged commit 8f8be1a into main Oct 7, 2026
29 checks passed
@fuziontech
fuziontech deleted the feat/admin-trino-queries-view branch October 7, 2026 14:33
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.

2 participants