Skip to content
Last updated

Reading Query Results

WebDesktopMobile

A query in Studio produces two different things, and telling them apart is what keeps you out of trouble: the raw output, which sits inside the tool call the agent ran, and the agent's account of it, which is the prose and the tidy table in its reply. The first is what the query engine returned. The second is generated text about it. This page covers how to read both, and how to get a result set out of the chat when you need the whole thing.

Note

Studio does not render query output as an interactive table. There is no sorting, filtering, or export in the chat, and no execution-stats row — the output is text, and anything more structured comes from writing it to a file.

How you read a result is the same whichever source it came from. The tdx specifics on this page — the row cap, the output flags — apply to your Treasure Data CDP; a connected warehouse returns whatever its own connector returns.

Prerequisites


Where the Raw Output Lives

Expand the query's tool call in the chat. Inside it you get the command that ran and, below it, the output exactly as tdx query printed it — a monospace block, in whatever format the agent asked for (the default box-drawing table, or JSON if it used --json).

Two details shape what you see:

  • Long output is cut at 12 lines, with a Show N more lines toggle to reveal the rest.
  • The row carries a duration badge when the call took a second or longer, and an Exit badge when the command failed.

The Copy button on the tool call copies the command, which is the fastest way to re-run a query yourself in Treasure Code or the console.

The Table in the Reply Is a Restatement

When the agent answers, it usually formats the numbers as a markdown table or a short summary. That table is written by the model from the output it read — it is not a rendering of the result set. Most of the time it is faithful. It can also drop a row, round a figure, or reorder columns, and nothing in the interface marks the difference.

So when a number matters, check it against the tool call rather than the prose. If the two disagree, the tool call is the record.

Warning

This applies with more force to the analysis that follows the numbers. "Revenue is up 23% because the loyalty campaign landed" contains a figure the query produced and a cause the model inferred — see The Interpretation Is Generated Text.

Getting a Full Result Set Out

tdx query limits itself to 40 rows only on an interactive terminal. The sandbox has none, so an unbounded query returns everything into the tool output — most of it hidden behind the truncation, and all of it taking room the AI would otherwise have for the rest of the conversation.

When you want the complete result, take it out of the chat:

  1. Ask the agent to write the query to a file: tdx query --output results.csv "SELECT ..." (--json, --jsonl, and --tsv are available too)
  2. Open the file in the spreadsheet viewer for a read-only look, with sheet tabs for a multi-sheet workbook
  3. Download it from the file card or the file panel if you need it locally

A file written inside a work folder stays there after the chat is gone, which also makes this the way to keep a result past your organization's retention period.

Charting a Result

Treasure AI Studio has no chart engine. Ask for a chart and the agent does what it does with any other deliverable: it writes a file and opens it. Usually that is a self-contained HTML page shown in the HTML viewer; it can also be a Mermaid diagram or a plain image. There is no chart panel, no chart type menu, and nothing to configure after the fact.

That has three practical consequences:

  • Ask in words, not by picking a type. "Plot daily signups for the last 30 days as a line chart" gets you a line chart. Describing the question instead — "show me how signups moved after the launch" — leaves the choice to the agent, which is fine until it picks something you did not want. Naming the chart is free.
  • Revising means regenerating. The chart is a file, so a change is a new version of that file. Ask in the same chat — "make it a bar chart", "break it down by region", "sort descending" — and the agent rewrites it, with the query result still in context.
  • What it looks like depends on what wrote it. Charting comes from the same plugins that supply document generation, not from Studio itself. A "dashboard" is one more HTML file on the same footing — several charts in one page — not a Studio feature with its own layout rules or saved state.
A blank chart is usually a blocked download

Chart HTML often pulls its charting library from a public CDN, and the file only renders if that request succeeds — behind a restrictive network, it will not. If a chart opens blank while the query clearly returned rows, ask the agent to inline the chart library into the file rather than loading it from a CDN, and to regenerate.

Charts are worth the same suspicion as the table in the reply: the agent writes the data into the chart file by hand, so a chart can disagree with the query that produced it. When a chart is going in front of someone else, check a couple of its values against the tool call first.

When a Query Fails

A failed query shows as a tool call with a warning icon and an Exit badge. Expand it: the engine's error text is in the output, under the statement that caused it.

ErrorCauseWhat to do
Table not foundWrong database or table nameAsk the agent to run tdx databases, then tdx tables <db>, and re-run against the right name
Column not foundMisspelled or non-existent columnAsk for tdx describe <db.table> and correct the query
Permission deniedYour account cannot read that database — or it can query the database but not download the resultConfirm the database with your administrator; the agent runs with your own permissions. A statement that runs and then fails at retrieval is the second case, which requires the Download database permission — see Fetching Results Requires the CDP Download Permission
Syntax errorInvalid SQLRead the statement in the tool call. If the same shape of error keeps recurring, the SQL skills are probably off — see Turn On the SQL Skills
Memory or resource errorThe query is too heavy for TrinoAsk the agent to narrow the time range. If the query genuinely needs Hive, it has to be submitted as a job rather than run with tdx query — see Trino Runs in the Chat; Hive Runs as a Job

Finding the Job in the Console

Studio does not print a job ID beside the results. To trace a query in the Treasure AI console — for the execution plan, resource usage, or logs — ask the agent to list recent jobs with tdx jobs, match yours by time and statement, and look that job up in the console. See tdx job.

Verification

  • Expand a query's tool call and read the raw output under the command
  • Compare a figure in the agent's reply against that output
  • Ask for a result as a CSV file and open it in the spreadsheet viewer

Troubleshooting

IssueSolution
The output is cut offExpand the tool call and use Show N more lines. If the result is genuinely large, write it to a file instead of reading it in the chat
The agent's table and the raw output disagreeTrust the tool call. Ask the agent to re-read the output and correct itself, and re-check any figure you have already acted on
You want to sort or filter the resultsNeither is available in the chat, and the spreadsheet viewer does not sort or filter either. Re-run with ORDER BY / WHERE, or export to a file and download it to open in Excel
The chat became slow or forgetful after a big queryA large result leaves little room for the rest of the conversation. Start a new chat for the next question, and keep results in files — see In-Session Memory

Next Steps