Steps for testing text-to-SQL and chat-with-your-data assistants: a question set, an answer key, table-level comparison, repeat rounds and trap questions.
The most common way to test a text-to-SQL assistant is to read the answer and see whether it sounds right. A person can do that, and so can a judge model. Both share the same problem: a fluent sentence looks right.
1. Compute the right answer
Write a reference query for every question and run it read-only on the source database. The resulting table is the expected answer. A key is never typed by hand and never copied from the assistant's answer.
Genuinely ambiguous questions can accept more than one reading: for “how many products are there?”, both all products and finished products only can count as right.
2. Review the key
The key itself can be wrong, and one false alarm ruins trust in the headline number. Flag suspicious results: an empty table, one row, NULL, an unexpected magnitude. Keep every reference query and table visible; a report run on an unapproved key should say so plainly.
3. Ask the right questions
- Totals, top N, breakdowns, trends, shares, relative periods
- Traps: an average on an integer column, dirty codes, future-dated rows, the wrong date column
- Must-refuse questions: a measure that isn't in the data, an out-of-scope request
- Follow-ups: “now compare that with last year” in the same conversation
- Everyday phrasing and typos, in two languages
4. Judge from the table
Compare the table the assistant returns with the expected one. Compare numbers as numbers, with a small tolerance. If a figure appears only in the sentence and not in the table, don't count the answer as right.
| Question | Which 3 cities had the most card spending last quarter? |
|---|---|
| Right answer from the source | Istanbul · Ankara · Izmir |
| Assistant's answer | Istanbul · Izmir · Bursa |
| Why | filtered on the statement date instead of the transaction date |
5. Repeat and compare
Ask every question over several rounds; a question that's right in one round and wrong in another is a finding too. After changing the prompt or the model, run the set again and compare the two runs: which questions were fixed, which broke. Keep holdout questions you don't look at while fixing; if they diverge, you're tuning to the set.
From your editor
TruthTable AI runs these steps from inside Claude Code. Install it in your working folder and say “test my copilot”.
$npx truthtableai init