Skip to content

server,ui: surface query metadata as top-level fields on StatementDetailsResponse#169971

Merged
trunk-io[bot] merged 5 commits into
cockroachdb:masterfrom
kyle-a-wong:stmt_details_query_metadata_api
May 13, 2026
Merged

server,ui: surface query metadata as top-level fields on StatementDetailsResponse#169971
trunk-io[bot] merged 5 commits into
cockroachdb:masterfrom
kyle-a-wong:stmt_details_query_metadata_api

Conversation

@kyle-a-wong
Copy link
Copy Markdown
Contributor

Summary

Surface query, query_summary, and database as new top-level fields on
StatementDetailsResponse, sourced from the dedicated columns on
crdb_internal.statement_activity / _statistics_persisted /
_statistics (which themselves coalesce from system.statements). The
DB Console statement details page reads from the new fields and falls
back to the existing AggregatedStatementMetadata.query /
.databases for compatibility with older servers.

This unblocks the next phase of stmt-stats work that stops persisting
query/database/query_summary inside the metadata JSONB column.

Approach

  • Proto adds three top-level string fields to StatementDetailsResponse.
  • Server (statement_details.go) projects max(query), max(query_summary), max(database) from the source view in getTotalStatementDetails and threads them onto the response. Gated on clusterversion.V26_3 so mixed-version clusters that may route the IE query to a node missing the columns don't break.
  • UI: three small resolver helpers (resolveQuery, resolveQuerySummary, resolveDatabase) in pkg/ui/workspaces/cluster-ui/src/statementDetails/queryMetadata.ts prefer the new fields and fall back to the deprecated metadata.* reads. statementDetails.tsx, planDetails.tsx, and plansTable.tsx switch to the resolvers; database (invariant per fingerprint) is threaded down as a prop instead of being read per plan.

Commit structure

Five commits, each independently reviewable: proto fields, server wiring (with test), UI resolvers, UI consumer updates, fixture updates.

Epic: none

Release note: None

@trunk-io
Copy link
Copy Markdown
Contributor

trunk-io Bot commented May 8, 2026

😎 Merged successfully - details.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@blathers-crl
Copy link
Copy Markdown

blathers-crl Bot commented May 8, 2026

Detected infrastructure failure (matched: self-hosted runner lost communication with the server). Automatically rerunning failed jobs. (run link)

@kyle-a-wong kyle-a-wong marked this pull request as ready for review May 11, 2026 13:55
@kyle-a-wong kyle-a-wong requested review from a team as code owners May 11, 2026 13:55
@kyle-a-wong kyle-a-wong requested review from angles-n-daemons and removed request for a team May 11, 2026 13:55
@kyle-a-wong kyle-a-wong force-pushed the stmt_details_query_metadata_api branch from edfdefc to cc23ac5 Compare May 13, 2026 13:55
…Response

Add top-level query, query_summary, and database string fields to
StatementDetailsResponse. These will be populated from the dedicated columns
on the statement statistics views in a follow-up commit.

Release note: None
…umns

Once V26_3 is active, getTotalStatementDetails projects the dedicated
query, query_summary, and database columns from the source statement
statistics view (activity / persisted / combined), and getStatementDetails
sets the corresponding top-level fields on StatementDetailsResponse.

Pre-V26_3, the new fields are left empty so consumers continue to read
the deprecated metadata.query / metadata.databases fields.

Release note: None
…elpers

Add three small resolvers that prefer the new top-level Query / QuerySummary
/ Database fields on StatementDetailsResponse and fall back to the
deprecated AggregatedStatementMetadata fields. Used by callers in the
statement details page in subsequent commits.

Release note: None
…elds

Switch the statement details overview, explain plan, and plans table to
read query / database from the new top-level fields on
StatementDetailsResponse via resolveQuery / resolveDatabase. The deprecated
AggregatedStatementMetadata.query / .databases reads remain as a fallback
inside the resolvers for compatibility with older servers.

Database is threaded down to PlanDetails / PlanTable / makeExplainPlanColumns
as a prop (it is invariant across plans for a given fingerprint), replacing
the per-plan plan.metadata.databases[0] reads.

Release note: None
…xtures

Set the top-level Query / QuerySummary / Database fields on the existing
statement details fixtures so storybook snapshots and component tests
exercise both the new and fallback (metadata) code paths.

Release note: None
@kyle-a-wong kyle-a-wong force-pushed the stmt_details_query_metadata_api branch from cc23ac5 to 2e731df Compare May 13, 2026 14:04
@kyle-a-wong
Copy link
Copy Markdown
Contributor Author

/trunk merge

tftr!

@trunk-io trunk-io Bot merged commit 39a62a3 into cockroachdb:master May 13, 2026
37 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants