ArticlesResearch6 min read
Semantic layer vs text-to-SQL: we asked 200 questions of the warehouse dbt Labs tested
dbt Labs found a semantic layer beat text-to-SQL on 11 questions. We asked 200 of the same insurance warehouse. Modeling the warehouse helped, as they found. A metric layer drafted by AI did not.
Kranthi Kondapaka, founder of ZLens · Checked on 26 November 2026
In dbt Labs’ 2026 test, a semantic layer beat text-to-SQL once the warehouse was modeled. We asked 200 questions of the same insurance warehouse and agree that modeling helps a lot, but in our test a metric layer drafted by AI lowered accuracy and put an official-looking label on wrong answers.
Both results are real. They measure different things.
What dbt Labs tested
On 7 April 2026, Jason Ganz and Benoit Perigaud of dbt Labs published Semantic Layer vs. Text-to-SQL: 2026 Benchmark Update. They used data.world’s ACME insurance benchmark, packaged with a dbt project in dbt-labs/dbt-llm-sl-bench, and asked 11 questions, 20 times each.
On the original schema, text-to-SQL scored 64.5% with both Claude Sonnet 4.6 and GPT-5.3 Codex, and the semantic layer 72.7%. The semantic layer got every question in its scope right and scored 0.0% on the questions that needed too many entity hops for MetricFlow, returning an error rather than a number. They then had an AI model write 3 new dbt models and added them to the text-to-SQL prompt, which held the entire schema.
dbt Labs’ result after modeling
Accuracy as dbt Labs reported it after adding 3 models: 11 questions, each run 20 times.
| Model | Text-to-SQL | Semantic layer |
|---|---|---|
| Claude Sonnet 4.6 | 90.0% | 98.2% |
| GPT-5.3 Codex | 84.1% | 100.0% |
They advise text-to-SQL for ad hoc questions and smaller datasets, and a semantic layer where accuracy is critical and the data is large or messy. Their strongest point: the semantic layer said when it could not answer, while text-to-SQL could return a plausible wrong number. That is a fair reading of their data.
What we tested on the same warehouse
We used the same ACME warehouse as dbt Labs packaged it, loaded into DuckDB: 29 tables. We published the test plan before the run. A GPT model wrote 200 questions the data can answer and 50 it cannot. Claude Sonnet 5.5 answered every question in each setup, and an answer counted only if it returned the reference rows.
Same AI model, same 200 questions, five setups
Share answered exactly right on our pre-registered final set, Claude Sonnet 5.5.
| Setup | Exactly right |
|---|---|
| One-shot SQL from the table definitions | 59.5% |
| Agent with database tools | 70.5% |
| Same agent, plus our model of the warehouse and its metrics as text | 80.5% |
| ZLens: warehouse catalog, model and metrics | 87.5% |
| ZLens: the same, plus a business layer of AI-drafted metrics | 83.0% |
The model of the warehouse says which tables hold which business things and how they join. A separate Claude agent wrote it without seeing the questions. The metrics were dbt Labs’ MetricFlow metrics, rewritten as ZLens definitions.
Letting the AI look around the database added 11 points, and the model of the warehouse 10 more. On an earlier set of 40 questions, adding the model raised all seven AI models we tried, by 8 to 18 questions. Almost all of ZLens’s 87.5% was SQL the AI wrote with that context: 196 of its 200 answers were AI-generated, and only 4 carried a governed label.
Then the business layer: metric definitions drafted by AI agents from a business brief, checked by a second agent and certified by a person. With it, ZLens scored 83.0% against 87.5% without it, and 14 of the 45 answers it labelled governed were wrong. On an earlier set of 200 questions, 13 of its 26 governed answers were wrong.
Our labels fell short with dbt Labs’ metrics too: 36 of 54 governed answers were right under the strict grade, against our own target of 95%. Most misses were in the columns ZLens returned, not the numbers, and I count them against ZLens, not dbt’s definitions.
Where we agree with dbt Labs
Modeling the warehouse helps both approaches. dbt Labs saw text-to-SQL with Claude Sonnet 4.6 go from 64.5% to 90.0% after 3 new models that an AI wrote. Our agent went from 70.5% to 80.5% when it got our model of the warehouse, which an AI wrote, with its metrics as text. We also agree that numbers people rely on should come from definitions a team owns, not from SQL an AI writes fresh each time.
Where we differ
dbt Labs’ semantic layer failed safely: when it could not answer, it returned an error. In our test, the metric layer was where confident wrong answers came from. Of the 15 questions ZLens got right without the business layer and wrong with it, 11 were answered under a governed label, by metrics applied to questions they did not fit.
Part of that is the tools. MetricFlow refuses a query it cannot plan, while ZLens, in the build we tested, could apply a metric that covered only part of a question and keep the label. Part of it, I think, is who wrote the metrics. Under a lenient grade with rounding, 1 of the 54 governed answers built on dbt Labs’ metrics was still wrong, against 10 of 45 with the AI-drafted layer.
So the lesson, plainly: a semantic layer helps when people define the metrics and check its answers against numbers they trust. Drafting metrics with AI and trusting the label is where it went wrong for us. A person certified our business layer, and that was not enough.
Honest limits
- Different questions. dbt Labs asked 11 questions 20 times each, with 3 added models in the text-to-SQL prompt. We asked 200 different questions with a different AI model. Our 59.5% one-shot score cannot be set against their 90.0%.
- Our business layer is not MetricFlow. It was metrics drafted by AI and applied by ZLens. We did not run dbt’s semantic layer on our questions.
- A small warehouse. 29 tables is small. It says nothing about a 4,000-table account.
- Not Snowflake. We ran on DuckDB. We did not test Snowflake semantic views, Cortex Analyst or Snowflake CoWork.
What this means if your data is in Snowflake
In Snowflake, semantic views are where a team can keep metric definitions next to the data. Whatever layer holds your metrics, check the numbers it gives against a report people already trust before you call them official. A governed label says how an answer was made, not that it fits the question.
ZLens labels every answer Certified, From Metrics or AI-generated, and says Not in this data when the data cannot answer. You certify an answer only after ZLens compares it value by value with the CSV or Excel export of the report people trust. See how the report check works and how ZLens labels answers.
What we saw
I went through the wrong governed answers on the earlier 40-question set, and they did not look wrong. One question asked for a growth rate and got the yearly figures the rate is built from. Another asked for a correlation and got a breakdown by group. A ratio asked for as a percentage came back as a fraction. In several, ZLens’s own notes said part of the question was not covered, and the answer still carried the governed label. The metric was right. The answer was not.
Questions people ask
Is a semantic layer more accurate than text-to-SQL?
In dbt Labs’ test, on the questions its metrics covered, yes: 98.2% and 100.0% against 90.0% and 84.1% for text-to-SQL. In our test on 200 questions, adding a metric layer drafted by AI lowered accuracy from 87.5% to 83.0%.
Does a semantic layer stop AI from making up numbers?
It stops the AI inventing a formula for a metric the layer covers. It does not stop a metric being used for a question it does not fit. In our test, a business layer drafted by AI put a governed label on 14 wrong answers out of 45.
Is 87.5% good enough for board numbers?
No. On 200 questions about one 29-table warehouse, about 1 answer in 8 was wrong, and nothing in an answer said which. A number that has to be exact needs a person to check it against a report people trust, then certify it.
Can I run this benchmark myself?
Yes. The questions, run reports and a script that fetches the data are public in github.com/duckcode-ai-labs/dql-benchmarks. dbt Labs’ benchmark is in github.com/dbt-labs/dbt-llm-sl-bench.
Try it or read more
Read the full write-up of our benchmark. The paper is on Zenodo as DOI 10.5281/zenodo.24329320, with its questions and run reports in github.com/duckcode-ai-labs/dql-benchmarks.
ZLens is open source at github.com/duckcode-ai-labs/zlens. If your data is in Snowflake, ZLens for Snowflake runs inside your own account and is free on Snowflake Marketplace. More guides.
Sources
Checked on 26 November 2026.
- Jason Ganz and Benoit Perigaud, Semantic Layer vs. Text-to-SQL: 2026 Benchmark Update, dbt Developer Blog, 7 April 2026.
- dbt Labs, dbt-llm-sl-bench, GitHub.
- data.world, cwd-benchmark-data: the ACME insurance schema, data and questions, GitHub.
- Kranthi Kondapaka, Context, Trust Labels and Abstention in a Governed Text-to-SQL Layer: A Pre-registered Evaluation on an Insurance Warehouse, DuckCode AI Labs, November 2026. DOI 10.5281/zenodo.24329320.
- DuckCode AI Labs, dql-benchmarks: questions, test plan and run reports, GitHub.
dbt and MetricFlow are trademarks of dbt Labs, Inc. ZLens is not affiliated with or endorsed by dbt Labs.