What happens when you ask an AI assistant a question whose answer lives in a spreadsheet, a database, or a knowledge graph rather than in a paragraph of prose? Retrieval-augmented systems are famous for handling documents. Structured data is a different animal. A table has rows, columns, types, and joins. A database has schemas, keys, and constraints. An answer that is “roughly right” in a document summary is simply wrong when the question is “how many units shipped in March?”
That mismatch is the heart of AI structured data retrieval: the craft of getting a model to find, read, and reason over data that has a shape. It is harder than it looks, it fails in specific and predictable ways, and the ways teams measure it are still maturing. (A clearer way to track cloud data transfer costs)
What makes structured retrieval different from document search
In classic document retrieval, a system embeds text chunks and returns the closest matches. The original retrieval-augmented generation framework combined a retriever with a generator, and it was designed around unstructured text. That design choice matters: a passage can be read in isolation, but a table cell almost never can. The value of “42” depends entirely on its column header, its row label, and the filter that produced it.
Structured retrieval therefore splits into distinct sub-problems:
- Finding the right source. Which table, view, endpoint, or graph node set contains the answer?
- Linking language to schema. Mapping a user’s words onto actual table and column names.
- Constructing a query or read path. Writing SQL, SPARQL, or a structured API call.
- Executing and validating. Running it, checking the result, and presenting it faithfully.
Each step has its own failure modes, and a system that is 90% accurate at each of four steps is only about 66% accurate end to end. That compounding is the single most underrated fact about this work.
Ask a model “who bought the most widgets last quarter?” and it must decide whether “widgets” maps to `product_name`, `sku`, `category`, or a junction table. This mapping step is called schema linking, and it is where most text-to-SQL systems quietly fall apart. Real enterprise schemas are large, inconsistently named, and full of legacy columns like `cust_id_v2_old`.
The BIRD benchmark was built specifically to stress this, using large, messy databases rather than clean academic ones. Its designers treat schema linking as a first-class challenge, not an afterthought. The older Spider benchmark established cross-domain text-to-SQL evaluation over hundreds of databases, and its evaluation methodology is worth reading closely: it scores execution accuracy rather than string matching, because many differently written queries return the same correct rows.
Practical lesson: if you are building this, invest in schema documentation before you invest in prompt engineering. Column descriptions, sample values, and clear naming do more for accuracy than a cleverer prompt.
Tables as a retrieval target

Not every structured question needs SQL. Often the “database” is a single table in a document, a CSV, or a wiki page. WikiTableQuestions introduced complex, compositional questions over Wikipedia tables and remains a foundational dataset for table question answering. The word compositional is the key: “which of these players had more goals than the top scorer in 2018?” requires chaining lookups, comparisons, and aggregation.
In practice, table retrieval works best when the system does three things:
- Retrieves the table using its surrounding context, rather than only its cells, because headers and captions carry meaning.
- Serializes the table with a fixed approach. Row-by-row text, markdown, and JSON perform differently, and consistency matters more than the chosen format.
- Requires the model to cite the row and column it used, which reveals silent errors.
A common mistake is dumping an entire large table into the context window. Models lose track of rows in long tables and start inventing values that look plausible. Retrieving a relevant slice first, then reading it, is far more reliable.
Hybrid retrieval earns its keep
Pure dense retrieval is excellent at matching meaning but weak at exact identifiers, and structured data is full of exact identifiers: order numbers, SKUs, ISO codes, account IDs. Dense Passage Retrieval showed dual-encoder dense retrieval beating sparse BM25 on open-domain question answering, which is why dense methods became the default. But for structured sources, the honest answer is that you usually want both. (How to review access to a retrieval index)
A hybrid retriever runs a sparse keyword search alongside a dense one and merges the rankings. When a user types an exact part number, the keyword side wins. When they describe a category in their own words, the dense side wins. If you are tuning this layer, a practical checklist for evaluating retrieval quality is a good place to start, because most teams measure the generator and ignore the retriever that feeds it.
Text-to-SQL in production: what actually works
The gap between a benchmark demo and a production text-to-SQL feature is enormous. Here is what tends to separate the two.
| Practice | Why it matters |
|---|---|
| Curated semantic layer | Pre-defined metrics and joins remove ambiguity before the model sees it |
| Read-only, scoped credentials | Limits damage from a malformed or malicious query |
| Query dry-runs and cost checks | Catches expensive scans before they hit production |
| Result sanity checks | Flags empty or implausible result sets for review |
| Logged query plus result pairs | Gives you real evaluation data instead of guesses |
The semantic layer point deserves emphasis. If “revenue” means three different things across four teams, no model can resolve that. Defining metrics once, in a governed place, converts a language problem into a lookup problem, which is a much easier problem.
The access control point matters just as much. A retrieval index that serves structured data inherits every permission question the underlying database has. Reviewing access to a retrieval index is a discipline in its own right, and it is easy to get wrong when an assistant caches results across users. The same logic applies to multi-tenant systems, where separating tenant data in an enterprise assistant has to be designed rather than assumed.
Knowledge graphs and standards
When relationships matter more than rows, knowledge graphs take over. Questions like “which suppliers share a board member with our largest customer?” are graph traversals, not table scans. Benchmarks such as GrailQA and ComplexWebQuestions exist to test multi-hop reasoning over graph structure, where the model must chain several edges to reach an answer.
Underneath most knowledge graphs sit open standards. SPARQL 1.1 is the W3C Recommendation for querying RDF data, and it is the graph equivalent of SQL: a declarative language the model can generate and a store can execute. On the public web, Schema.org provides shared vocabularies for structured data markup, which is how search engines read facts out of pages. Both are worth understanding because they define what “correct” looks like when a model emits a query. (W3C Semantic Web standards overview)
Graph retrieval has a specific trap: generated SPARQL that is syntactically valid but semantically empty. A query can return zero rows and still look fine. Always pair graph retrieval with a coverage check that asks whether the returned subgraph actually connects the entities in the question.
Evaluating structured retrieval honestly
Benchmark numbers are seductive and often misleading. Reported scores change with prompt format, schema serialization, and execution environment. Cross-paper comparisons without a shared test setup are close to meaningless. If a vendor claims a text-to-SQL accuracy figure, the first question is which test setup produced it.
A more useful evaluation approach combines four layers:
- Execution accuracy on a held-out set of real questions from your own users.
- Schema-linking accuracy, measured separately, so you know whether failures are about finding or about writing.
- Refusal quality. Does the system say “I don’t know” when the data cannot answer the question? Overconfident wrong answers are worse than abstentions.
- Regression tracking as schemas change, because a renamed column silently breaks queries that used to work.
That last point is the one teams forget. Structured sources drift. Someone adds a column, deprecates a view, or changes a type. Retrieval systems need the same care as any other dependent service, including a recovery drill for a managed database so that a bad migration does not take the assistant down with it.
Common mistakes worth avoiding
A few patterns show up again and again in failed projects.
Treating structured retrieval as a prompting problem. Most accuracy gains come from better metadata, tighter scopes, and validation, not from a longer system prompt.
Skipping the intermediate representation. Letting a model jump straight from question to final answer, with no visible query, removes your ability to debug anything.
Ignoring units and time zones. A timestamp column without a documented zone will produce confidently wrong answers about “today.”
Forgetting the cost dimension. Analytical queries over large tables can be expensive, and an assistant that triggers full scans on every question will show up on a bill. Tracking cloud data transfer costs clearly is part of running this responsibly.
Testing only on clean data. Production tables have nulls, duplicates, and free-text fields stuffed into columns meant for codes. Evaluate on the messy version.
Conclusion
AI structured data retrieval is less about clever models and more about disciplined plumbing. The systems that work share a recognizable shape: well-documented schemas, hybrid retrieval that respects exact identifiers, a governed semantic layer, generated queries that are visible and validated, and evaluation that runs on the organization’s own messy data rather than a leaderboard. The models will keep improving. The plumbing is what you actually control, and it is where most of the accuracy lives.
Frequently asked questions
It is the process of using an AI system to find, query, and reason over data that has a defined shape, such as relational tables, spreadsheets, APIs, or knowledge graphs. Unlike document search, it usually involves generating a query like SQL or SPARQL and then validating the result before presenting it.
Why is text-to-SQL so hard for AI models?
The hardest part is usually schema linking: mapping a user’s everyday words onto the actual table and column names in a database. Large, inconsistently named, or legacy schemas make this much harder, and errors at this step compound through query writing and execution.
What is the difference between dense and hybrid retrieval?
Dense retrieval uses embeddings to match meaning, which handles paraphrased questions well. Hybrid retrieval combines that with keyword search, which is far better at matching exact identifiers like order numbers or product codes. For structured sources, hybrid usually wins.
How should structured retrieval be evaluated?
Start with execution accuracy on real questions from your own users, then measure schema-linking accuracy separately so you know where failures originate. Add checks on whether the system correctly refuses unanswerable questions, and track regressions as schemas change over time.
Can AI query knowledge graphs as well as databases?
Yes. Models can generate SPARQL, the standard query language for RDF graphs, to traverse relationships across entities. The main risk is producing valid but semantically empty queries that return nothing, so coverage checks on the returned subgraph are essential.
Do benchmarks like Spider and BIRD predict real-world performance?
Only loosely. Reported scores are sensitive to prompt format, schema serialization, and execution environment, so comparing numbers across papers is unreliable without a shared evaluation setup. Use benchmarks to understand capability, but validate on your own data before trusting a deployment.







