Data platforms · AI

Text-to-SQL agents need a semantic layer, not just a bigger model

'Ask your data anything' is one of the most requested AI features, and one of the most disappointing in production. The demo works on a tidy schema. The real warehouse has thousands of columns, conflicting definitions and tribal knowledge. Research and the market are converging on the same fix.

EssaySumanta Mukhopadhyay8 min read5 sources
#data#ai#ontology#agents
ESSAY · DATA PLATFORMS · AI26 Oct 2026 · 04:15 GST

Every data team has seen the demo: a business user types "what was revenue by region last quarter?" and the model writes perfect SQL. Then the same tool meets the real warehouse, with three tables that could be "revenue", a region column that changed meaning in 2023, and a fiscal calendar nobody wrote down. The answers come back quickly, confidently and wrong.

What the research shows

Spider 2.0, presented at ICLR 2025, was built from real enterprise workflows: 632 problems over databases often with more than a thousand columns, in systems such as BigQuery and Snowflake. The authors reported that a strong reasoning model using a code agent framework solved 21.3% of tasks, compared with 91.2% on the earlier Spider 1.0 benchmark and 73.0% on BIRD12.

The gap isn't mainly about SQL syntax. It is about knowing which tables matter, what columns mean, how entities join, and which business rules apply. That knowledge rarely lives in the schema.

Text-to-SQL fails on meaning, not grammar. A bigger model writes more fluent wrong queries; a semantic layer gives it the right things to query.

What a semantic layer gives an agent

A semantic layer defines business concepts, such as metrics, dimensions, entities and their relationships, once, in governed code, and exposes them to every tool. For an AI agent, that changes the task from "write SQL against 1,500 columns" to "pick the governed metric 'net revenue', group by the dimension 'sales region', filter to last fiscal quarter". The layer generates the SQL.

  • Consistency. The agent's answer matches the dashboard, because both use the same definition.
  • Smaller search space. Choosing from a curated set of metrics is far easier than reasoning over raw tables.
  • Governance. Access control, row-level security and certified definitions apply to AI queries just as they do to BI.
  • Explainability. The agent can say which metric and filters it used, in business terms a user can check.

The market is converging

In September 2025 Snowflake, Salesforce, dbt Labs and others announced the Open Semantic Interchange, an initiative for a vendor-neutral semantic model specification, explicitly framed around making data ready for AI3. In October 2025 dbt Labs moved MetricFlow, the engine behind its semantic layer, to the Apache 2.0 licence and said it would align it with that initiative45.

Whatever tools you choose, the direction is clear: business definitions are becoming portable, open artefacts that AI and BI share, rather than logic buried in each dashboard.

Semantic layer, ontology or both?

A semantic layer is optimised for metrics: numbers aggregated over dimensions. An ontology describes entities and relationships more broadly, as I set out in ontology vs knowledge graph vs semantic layer. For "how much" questions, the semantic layer is the right tool. For "which suppliers are connected to this incident", a knowledge graph answers better. Mature data platforms give agents both, with clear guidance on which to use.

How I design data access for AI agents

  1. Start with the twenty questions people actually ask, and define the metrics and dimensions they need in the semantic layer first.
  2. Expose governed tools, not a SQL console. Agents call "query metric" and "list dimensions" tools, for example through MCP servers built with the controls in securing MCP servers.
  3. Return the definition with the answer, so users see which metric, filters and time range were used.
  4. Fall back honestly. If a question can't be answered from governed definitions, say so and route it to an analyst, rather than improvising SQL.
  5. Evaluate with real questions and known answers, as in evaluation sets that predict production, and track accuracy by question type.
  6. Keep definitions under contract, with the change discipline in data contracts, so a schema change can't silently break what agents report.

How I can help

I design data platforms where AI agents and BI share governed definitions, from semantic layers and ontologies to the tools agents call. See ontology and knowledge graphs, or analyse your challenge and bring the result to a call.

References
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
    About MetricFlowdbt documentation
FAQ

Common questions

How good are LLMs at text-to-SQL on real enterprise data?

Much worse than on academic benchmarks. The Spider 2.0 benchmark, built from real enterprise workflows with very large schemas, reported that a strong reasoning model with an agent framework solved around a fifth of tasks, compared with over 90% on the earlier Spider 1.0 benchmark.

What is a semantic layer?

A governed layer of business definitions, such as metrics, dimensions and relationships, that sits between raw tables and the tools that query them, so that 'revenue' or 'active customer' means the same thing everywhere.

Should AI agents query raw tables at all?

For most business questions, no. Agents are more reliable when they query governed metrics and entities through a semantic layer, with raw-table SQL reserved for analysts or carefully scoped exploration.

Keep reading

Related

Open to advisory, fractional CTO & select builds

Let's talk about what you're building.

The fastest route is a free 30-minute call. Prefer to write? Send a message and I'll reply personally within two business days.

Start a conversation

How would you like to reach me?

Book a 30-min callFastest. Pick any open slot on my calendar.→ Write in GmailOpens a pre-filled draft in your browser.→ Use my email appOutlook, Apple Mail or your default client.→

I reply personally within two business days. Time zones from the Americas and Europe to the Middle East and Asia-Pacific.