Semantic Layer vs Text-to-SQL for AI Data Agents: What the 2026 Benchmark Does and Doesn't Prove
A vendor-run benchmark, a changed data model, and a decision rule for when raw SQL is still fine
On the evidence we have, yes, a semantic layer is more accurate than raw text-to-SQL for AI data agents, but the evidence is narrow. In its 2026 benchmark, dbt Labs reports Claude Sonnet 4.6 scoring 98.2% through a semantic layer against 90.0% for text-to-SQL, on 11 questions each run 20 times. The direction held in every configuration reported. But the benchmark is vendor-run, small, and changed the data model between runs. Keep raw text-to-SQL for exploration, and put a semantic layer in front of any number someone will act on.
Key Takeaways
- •In dbt Labs' 2026 benchmark, the semantic layer scored higher than text-to-SQL in every configuration reported, so the direction of the result is credible.
- •The headline gap is smaller than it looks: adding three dbt models raised text-to-SQL from 64.5% to 90.0% for Sonnet 4.6, so most of that improvement came from better data modeling, not from the semantic layer itself.
- •A semantic layer fails by refusing: out-of-scope questions scored 0% for it, while raw text-to-SQL kept answering, sometimes wrongly and sometimes correctly.
- •The benchmark is 11 questions on one insurance dataset, published by the vendor of the semantic layer under test. Treat it as a strong hint, not a measurement of your warehouse.
- •Use a semantic layer for governed metrics (board numbers, KPIs, audits) and raw text-to-SQL for read-only exploration where a person checks the SQL.
What the dbt benchmark actually measured
The test uses the ACME Insurance dataset, originally built by Juan Sequeda and colleagues at data.world. Per the dbt write-up, it holds 11 questions, each run 20 times across several models, in four configurations: text-to-SQL, a minimal semantic layer, a modeled semantic layer, and text-to-SQL on the modeled data. Two models carry the headline: claude-sonnet-4-6 and gpt-5.3-codex.
On the original schema, both models scored 64.5% with text-to-SQL. The semantic layer scored 72.7% across all questions, but 100.0% on the questions it could express. The questions it could not express count as zero, because the original third-normal-form schema needed more entity hops than MetricFlow supports. That is why the all-questions number looks modest while the in-scope number is perfect.
After the data model changed, the reported figures were 90.0% (text-to-SQL) and 98.2% (semantic layer) for Sonnet 4.6, and 84.1% against 100.0% for gpt-5.3-codex. Those are the numbers circulating in the debate, so it helps to know they come from the second round, not the first.
Why part of the jump is a data-model effect
Between the two rounds, dbt prompted an LLM to create as few dbt models as possible so that all 11 questions became answerable through the semantic layer. It produced three models that joined tables and defined matching semantic models, and the authors say they wrote no code for this step. The text-to-SQL context was updated with the new tables and relationships as well.
That matters for the comparison. Text-to-SQL on Sonnet 4.6 rose from 64.5% to 90.0%, a gain of 25.5 points, without any semantic layer involved in answering. The semantic layer's lead over text-to-SQL shrank from 37.5 points on in-scope questions in the first round (100.0% against 62.5%) to 8.2 points for Sonnet 4.6 in the second round.
So two effects are tangled together: the semantic layer's own contribution, and the contribution of a cleaner, pre-joined data model. The benchmark is honest about the modeling step, but it does not separate the two. We would read it as evidence that modeling the data for questions matters a great deal, and that a semantic layer adds a further, smaller edge on top.
What the result does not prove
First, scale. Eleven questions on one dataset is a small sample, and a single question flips a score by roughly nine points before the 20 repeat runs average out noise. Second, the authors state that to make text-to-SQL work they loaded the entire schema into context, which they call impractical for larger datasets. A raw-SQL agent on a real warehouse would need retrieval over thousands of tables, a harder problem than the one tested.
Third, independence. The post appears on dbt's own docs site, and the semantic layer under test is dbt's. That does not make the numbers wrong, but nobody outside the vendor has run it blind. The out-of-scope rows also show a quirk: gpt-5.3-codex scored 100.0% on text-to-SQL for those questions where the semantic layer scored 0%, which the post reports without comment.
Earlier work points the same way. The data.world authors' 2023 paper reported GPT-4 accuracy of 16% directly on SQL databases against 54% over a knowledge-graph representation. Because the 2026 benchmark builds on that dataset lineage, the two results are consistent but not independent confirmations. We would want a replication on a messier warehouse before treating the gap as settled.
A decision rule for when raw text-to-SQL is still fine
dbt's own guidance is a good starting point: use the semantic layer when accuracy matters, such as board data, audits, OKRs and weekly reports. For ad hoc exploration, check whether the semantic layer can answer first, then whether small modeling changes would close the gap, and only then fall back to text-to-SQL with as much schema context as possible. We agree, and add a few conditions.
- •Use a semantic layer when the answer becomes a number in a deck, a contract or an alert, because a metric defined once cannot drift between askers.
- •Use raw text-to-SQL when the question is exploratory, the connection is read-only, and a person will read the generated SQL before trusting the result.
- •Use raw text-to-SQL when the question is genuinely new and no metric exists yet, then promote any query that gets reused into the semantic layer.
- •Do not use raw text-to-SQL for write paths, access decisions or anything an agent will act on without review.
The failure modes differ, and that is the real reason for the split. The authors write that the semantic layer tells you when it cannot answer, while text-to-SQL can return a confident wrong number. A refusal costs a person a few minutes. A silent wrong answer in a board metric costs trust.
How a data agent should route between the two
In practice an agent should not pick one forever. It should try the governed path first and fall back deliberately. Expose metric queries as one tool and read-only SQL as a second, and let the agent say which it used. Our Insights Agent works this way: it grounds text-to-SQL in the semantic layer and returns the assumptions it made, so a reader can see whether an answer came from a governed definition.
Tool design carries part of the safety load. The MCP tools specification says servers must validate all tool inputs and implement access controls, and that clients should prompt for confirmation on sensitive operations and keep a human in the loop with the ability to deny tool invocations. Those rules apply to any raw-SQL tool you expose, however accurate the underlying model is.
The fallback also needs a signal. When the agent drops from the metric tool to raw SQL, the answer should be labeled ungoverned, and any query that keeps being asked should become a candidate metric. Over time the semantic layer grows from real questions instead of from a modeling backlog nobody reads.
How to run this test on your own warehouse
Do not adopt either approach on the strength of someone else's 11 questions. Collect 30 to 50 questions your team actually asks, with answers a human has verified. Split them into those a semantic layer can express and those it cannot, as dbt did with its in-scope and out-of-scope rows. Run each question several times, since single runs hide variance.
Score three outcomes separately: correct, wrong, and declined. The most useful column is wrong, because that is the one that damages trust. A configuration that answers 95% correctly and 5% wrong is worse for finance than one that answers 85% correctly and declines the rest, and an aggregate accuracy figure hides that difference.
Finally, change one thing at a time. Test raw text-to-SQL on your current schema, then on a cleaned schema, then through a semantic layer. If the cleaned schema recovers most of the gain, invest in modeling first. That is the control the 2026 benchmark could not fully provide, and it is the cheapest experiment you can run.
Frequently Asked Questions
Is a semantic layer always more accurate than text-to-SQL?
No, and the evidence does not claim it. The semantic layer scored higher in every configuration dbt reported, so the evidence points one way. But it is a single, vendor-run benchmark on 11 questions, and the semantic layer scored 0% on questions outside its modeled scope. Where a question is out of scope, raw text-to-SQL is the only option that answers at all.
Did the semantic layer cause the jump to 98.2%?
Only in part. Between rounds, three new dbt models were added, and text-to-SQL on Sonnet 4.6 improved from 64.5% to 90.0% on that modeled data alone. The semantic layer then added about eight more points. We read the result as mostly a data-modeling effect with a smaller semantic layer effect on top.
When should I still use raw text-to-SQL?
Use it for read-only exploration where a person reads the generated SQL, for brand-new questions with no defined metric, and as a fallback when the semantic layer declines. Avoid it for numbers that feed board reports, alerts or any action taken without review.
Do I need a semantic layer before building a data agent?
Not before you start, but before you trust it with governed numbers. Begin with read-only text-to-SQL, log the questions people ask, and model the repeated ones as metrics. That gives you a semantic layer shaped by real demand.