Level 2: AI layer
Route the question: governed metric first, curated query second, free-form SQL last.
“Semantic layer or text-to-SQL?” is the wrong argument. Use both, in a written order, and label every answer with the route it took.
On this page
There's a long-running argument about whether AI tools should answer data questions through a semantic layer or by writing SQL. It's the wrong argument. A semantic layer answers the questions you've modeled, consistently. Free-form SQL reaches questions nobody has modeled yet, with less certainty. You want both, in a fixed order, with every answer labeled by the route it took.
Use both, in order
dbt Labs reached a similar conclusion in its own 2026 benchmark write-up, a vendor test of 11 questions on a published benchmark, each run 20 times. It recommends checking whether the Semantic Layer can answer first, then whether a small modeling change would close the gap, and only then falling back to text-to-SQL. The order matters more than the tool.
Diagram · Route the question: governed metric first, curated query second, free-form SQL last
The five tiers
- Tier 0: verified answer. A reviewed answer set in advance for a known question. In Power BI that's a verified answer Preview. In dbt, a saved query plays a similar role.
- Tier 1: semantic query. The model picks a metric, dimensions and a time window from the catalog in part 4. The engine writes the SQL or DAX.
- Tier 2: curated query. Reviewed, parameterized SQL for questions you know about but haven't modeled as metrics yet.
- Tier 3: free-form SQL. Read-only and row-capped, on data the user is allowed to explore, and labeled as exploratory every time.
- Tier 4: decline. Say it can't be answered yet, and log the question.
Tiers 0 to 2 run reviewed logic once the request is set. Choosing the tier and the metric is still the model's call, which is why part 7 tests the route, not just the model.
Same question, two routes
Take the reference question: April 2025 net revenue for C-001 and P-01. At tier 2 it's a reviewed query with four parameters:
-- Tier 2: a reviewed query. The model -- fills in parameters; it never edits -- the SQL. SELECT SUM(amount) AS net_revenue FROM revenue WHERE customer = :customer AND product = :product AND reporting_date >= :period_start AND reporting_date < :period_end_exclusive;
With customer C-001, product P-01 and the April window, it returns 100.00. Tier 1 gets the same 100.00 from the metric in part 3, with a COMPLETE status attached.
Now the same question at tier 3, written from scratch by a model that thought contract details might matter:
-- Tier 3: free-form SQL that looks -- reasonable. Exploratory, not certified. SELECT SUM(r.amount) AS net_revenue FROM revenue r JOIN terms t ON t.customer = r.customer AND t.product = r.product WHERE r.customer = 'C-001' AND r.product = 'P-01' AND r.reporting_date >= '2025-04-01' AND r.reporting_date < '2025-05-01';
| net_revenue |
|---|
| 200.00 |
Result on the example. Example data, not from a client.
It returns 200.00. It's the guide 1 fan-out again, written fresh. Nothing errors, and the SQL reads fine. That's why tier 3 comes last, why it's labeled “exploratory, not certified,” and why I want the query shown next to the number. A reviewer can spot the join in five seconds. A reader looking only at 200.00 can't.
Write the order down
A routing order that exists only in your head isn't a routing order. Put it in the instructions your agent reads. Here's the version I start from:
Route every data question in this order. Use the first route that fits. 0. If it matches a verified answer, return that answer. 1. If it fits a catalog metric, its dimensions and a time window, call the metric tool. Never write SQL for a catalog metric. 2. If it matches a curated query, run it with parameters. Don't edit the SQL. 3. Only if exploration is allowed for this user and data, write read-only SQL. Label the answer "exploratory, not certified" and show the query. 4. Otherwise, say you can't answer it yet and log the question as a gap. Always report which route you used.
Platforms give you a place for this. A Fabric data agent can use instructions you write to pick the most relevant data source, so you can send metric questions to a semantic model and exploration to a lakehouse. In dbt, the MCP server offers Semantic Layer tools next to SQL tools, and the order lives in your agent's instructions.
Instructions guide the model; they don't bind it. That's why the important rules also live in the tools themselves, which is part 6.
The gap list is the backlog
List the 20 questions people actually ask, from tickets, chat history and report usage. Tag each with the first tier that can answer it. Anything that lands at tier 3 or 4 and comes up every week goes on the modeling backlog. Model it, and next month it answers at tier 1.
Over time the share of questions answered at the top tiers should grow. I don't quote a target. I watch the list of weekly tier 3 and tier 4 questions get shorter.
What I check in a routing setup
- Is the order written in the agent's instructions, in plain words?
- Does every answer report the tier it came from?
- Is free-form SQL read-only, row-capped, labeled exploratory and shown with its query?
- Are declined and tier 3 questions logged and reviewed as a modeling backlog?
Governed first. Exploratory last. Labeled always.
Related
- All 8 parts of this seriesSeries overview
- All the diagrams in one placeDiagrams
- Level 1: Model the data (7 guides)Read level 1
- The 4-question checklistChecklist