Track 07 · Data & governanceLesson 03 of 11
Agents over tables: text-to-SQL and beyond
Answer questions from structured data, safely and verifiably.
- The FDE path · Stage 3 of 6
- 45 min read
- 75 min hands-on
- Pro
What you'll be able to do
01- You can choose between free-form text-to-SQL, a semantic layer and parameterised query tools for a given question set and risk level.
- You can design schema-linking context: descriptions, join paths, sample values and verified queries.
- You can implement a guarded executor: read-only identity, SELECT-only validation, table allow-list, row caps, timeouts and row-level security.
- You can build an execution-accuracy eval and explain why result equivalence, not string match, is the metric.
- You can design self-correction, clarification and provenance so a wrong number is caught before it reaches a decision.
- You can defend the design to a sceptical CISO and a protective data-platform owner.
Before you start
- Typed output: schemas, validation and tool calls: the generator returns SQL inside a structured contract.
- Designing tools a model can use well: a SQL tool is a tool, and its error returns are a design surface.
- Tools with scoped, auditable access: which identity the query runs as.
- Golden datasets and the metrics that matter: how to build the golden set this file evaluates against.
- Is the data ready?: whether the tables are clean and joined enough to query at all.
- Background: you can read and write SQL with joins, GROUP BY and window functions.
The short version
An agent answering from tables can write SQL freely (text-to-SQL), compose queries from a curated vocabulary of metrics and dimensions (a semantic layer), or call reviewed parameterised queries as tools. They trade flexibility for control, and production systems mix them. Whatever writes the SQL, a deterministic executor enforces the rules: read-only identity, parser-based SELECT-only validation, a table allow-list, row and time limits, and row-level security in the warehouse. You measure it by executing generated and gold SQL and comparing results, never SQL strings. Every answer ships with provenance: SQL, tables, definitions and as-of time.
- Business definitions ("booked", "on time") are where answers go wrong. A semantic layer is where they live.
- Security belongs in the database; application checks are a second layer. A regex is not a boundary.
- Execution accuracy on your own golden set is the number that matters.
- Retry repairable errors. Never retry policy violations.
Pro lesson
The rest of this lesson is in Pro.
The mental model, worked example, field note, failure table, exercise and self-check, with the voice tutor.
Also in Pro
- Every stage and specialisation, in full
- Every lab and every role project
- Halden weeks 2–10, on your record
- Every drill, live in the playground
- All solutions, plus the server judge
- Lab Assistant and every Teach with AI