Skip to content
Last updated

Query Result Tables

WebDesktop

Every query result is a readable, structured table — right in the chat. Column types, numeric alignment, NULL handling, and execution stats are rendered automatically so you can scan results without switching to a spreadsheet.

Note

Query result tables are rendered client-side from the raw output of tdx query. The AI detects query output automatically and displays it as a structured table rather than plain text. No additional processing is required from you.

Objective

Read and interpret query results inline in the chat stream, including column types, formatted values, execution metadata, and error diagnostics.

Prerequisites

  • Signed in to Treasure AI Studio (Getting Started)
  • A completed query execution (see Query Execution)
  • Web or Desktop only — query result tables are not available on Mobile

Table Layout

Query result tables display inline in the chat, below the tool call that produced them. The table auto-expands when results are detected during streaming.

Structure

SectionDescription
Header rowColumn names in bold, with the column type displayed in smaller text below each name (e.g., varchar, bigint, double)
Data rowsQuery results with formatting based on data type
Stats rowExecution metadata below the table

The header row is sticky — it stays visible as you scroll through long result sets. The table has a maximum height of 300 pixels with vertical scrolling for large results, and horizontal scrolling for wide tables.

Column Types and Formatting

The table formats values based on the column type reported by the query engine.

Numeric Values

Columns with numeric types are right-aligned with tabular number formatting for easy column scanning. Recognized numeric types:

int, bigint, double, float, decimal, smallint, tinyint, real, long, number

All other types are left-aligned.

Special Values

ValueDisplay
NULLDisplayed as NULL in italic, muted text
trueDisplayed in green text
falseDisplayed in muted text
StringsDisplayed as-is

Row Highlighting

Hover over any row to highlight it with a subtle background — useful for tracking across wide tables with many columns.

Execution Stats

Below the result table, a stats row shows metadata about the query execution. The format is:

X rows · Processed Y rows · in Z · Job N

StatDescriptionExample
Row countNumber of rows returned42 rows
Processed rowsTotal rows scanned by the Trino engineProcessed 1.2M rows
Elapsed timeQuery execution duration (latency)in 3.2s
Job IDTreasure AI job identifierJob 987654321

Not all stats are present for every query. The stats row shows only the fields available from the query engine output.

Pro Tip

The Job ID can be used to look up the query in the Treasure AI console for detailed execution plans, resource usage, and logs. High "Processed rows" relative to returned rows may indicate missing partition pruning — use /sql-skills:trino-optimizer to diagnose.

Error Display

When a query fails, the result table is replaced by an error card:

The error card includes:

ElementDescription
Warning iconRed triangle indicating a failure
"Query failed" labelHeader text in red
SQLThe query that was executed, in monospace
Error messageThe full error text from the query engine
Job IDTreasure AI job identifier (when available)

Common error scenarios:

ErrorCauseFix
Table not foundWrong database or table nameAsk the AI to run tdx databases and tdx tables <db> to verify
Column not foundMisspelled or non-existent columnAsk the AI to run tdx describe <db.table> to check schema
Permission deniedInsufficient access to the databaseContact your Treasure AI administrator
Syntax errorInvalid SQLReview the SQL in the error card and correct the syntax

Reading Results in Context

Query result tables appear as part of the conversation flow. After the table renders, the AI typically provides analysis or next steps based on the results. For example:

  1. You ask: "What are the top 5 customers by revenue?"
  2. The AI runs: tdx query "SELECT customer_id, SUM(revenue) AS total ... LIMIT 5"
  3. A result table renders with 5 rows
  4. The AI summarizes: "Customer ID 12345 leads with $2.3M in total revenue..."

The AI can reference the results in subsequent messages because the query output is part of the conversation context.

Tool Call Integration

Query results live inside tool call indicators. Each query execution shows:

  1. Status icon — Spinning (running), green checkmark (completed), or red X (error)
  2. Description — What the tool is doing (e.g., the Bash command description)
  3. Command preview — The full command in monospace, truncated to one line
  4. Expand/collapse — Click to toggle the full command text and result
  5. Copy button — Appears on hover; copies the command text to your clipboard
  6. Duration badge — Shows execution latency if 1 second or longer (e.g., "3.2s")
  7. Exit code badge — Shows "Exit 1" (red) if the command returned a non-zero exit code

Query results auto-expand when detected during streaming, so you see the table without needing to click.

Technical Note

Tool call results longer than 12 lines show a "Show N more lines" link. However, query results bypass this truncation — they always render as a full QueryResultTable component with their own 300px scrollable viewport.

Current Limitations

The query result table is designed for viewing query output inline. The following features are not available in the current release:

  • Sorting — Columns are not sortable in the rendered table. To re-sort results, ask the AI to re-run the query with an ORDER BY clause.
  • Filtering — No client-side row filtering. Add WHERE clauses to your query for filtering.
  • Pagination — All returned rows display in a scrollable viewport (max 300px height). For large result sets, use LIMIT in your query.
  • Export — No direct CSV/Excel export from the table. To export results, ask the AI to save output to a file using tdx query --output results.csv "...".
  • Column resizing — Column widths are fixed based on content.
Pro Tip

For full spreadsheet features (sorting, filtering, resizing), ask the AI to save query results as a CSV or XLSX file. You can then open it in the Spreadsheet Viewer which supports sorting and resizable columns.

Verification

  • See column headers with type annotations (e.g., bigint, varchar) below each name
  • See numeric columns right-aligned and NULL values in italic muted text
  • See a stats row below the table with row count and execution time

Troubleshooting

IssueSolution
Table shows raw text instead of a formatted tableEnsure the command uses tdx query (not a raw SQL client) so the output includes the expected format that Studio can parse
Column types not shownType annotations appear below column headers. If missing, the query output may not include schema metadata — run the query via the AI rather than a direct command
Stats row not visibleThe stats row appears below the table only for queries executed via tdx query. Direct SQL output may not include execution metadata

Next Steps