Connect a Semantic Layer to LLMs for Natural Language Query

Connect a Semantic Layer to LLMs for Natural Language Query

How to connect a semantic layer to LLMs and AI agents: the request flow, entity resolution, permission checks, and a business-owned accuracy test.

By

Billy Allocca

Table of Contents

Last updated: December 1, 2026

To let people query enterprise data in plain language, route each question through a semantic layer that holds governed metric and entity definitions, have the model generate a query against those definitions instead of raw tables, and enforce the asker’s permissions before any data returns. Choose tooling on four criteria: where definitions live, how agents reach them, how permissions carry through, and how accuracy gets tested.

Explainability confidence runs well ahead of consistency. In NexusOne’s 2026 State of the Data Estate report, conducted by Enterprise Management Associates (EMA) in September 2026 (n=202) and commissioned by NexusOne, 96% of data and analytics decision-makers said they can tell fixed rules from model inference for at least some AI decisions, yet 62% said the same information produces materially different AI decisions at least occasionally [1]. Only 44% can make that separation for every decision, and among the 194 who can make it for some or all, 43% could show exactly which rules and data produced a decision in all cases [1].

Skipping the semantic layer leaves the model guessing what “revenue” means, and a guess can change from one run to the next. For which product to choose, see the 2026 comparison of semantic layer tools for AI agents.

What Is Natural Language Querying Over a Semantic Layer?

Natural language querying over a semantic layer is a pattern where a language model translates a plain-language question into a request for governed metrics and dimensions, and the semantic layer, which holds the reviewed definitions, writes and runs the SQL. Natural language querying (NLQ) means asking a data question in ordinary words and getting a computed answer. A semantic layer is a governed set of business definitions (metrics, dimensions, entities, and the joins between them) that sits between physical tables and every tool that queries them. Text-to-SQL is the narrower technique of having a model write SQL directly from a question and a schema.

The vendors that ship NLQ have converged on this division of labor, and dbt describes the goal as defining a metric like revenue once so a change “is refreshed everywhere it’s invoked” [6]. Looker’s Conversational Analytics uses the LookML model as its source of truth, and instead of querying the database directly it “determines which fields, filters, sorts, and limits should be used,” after which Looker builds the query [17]. dbt’s MetricFlow compiles metric requests into a query plan and then into SQL for a specific engine [9], and Snowflake’s Cortex Analyst generates SQL from semantic views that define logical tables, facts, dimensions, and metrics [11][12].

Criterion

What to check

Why it matters for NLQ

Where definitions live

Version-controlled files in a repository, objects in a warehouse, or a BI model

Determines who reviews a change and whether a rollback is possible

Agent access method

SQL or JDBC, REST or GraphQL, Model Context Protocol (MCP)

Determines which agents and assistants can call it without custom code

Who writes the final SQL

The model, or the semantic layer’s compiler

The compiler applies joins and formulas the same way every time

Permission inheritance

Whether queries run as the asking user or agent

A shared service account turns every question into a potential leak

Curated examples

Verified question and SQL pairs, synonyms, field descriptions

Gives the model tested patterns for common questions

Evaluation tooling

Built-in benchmark runs against expected results

Lets you measure accuracy after every definition change

Systems to update when a definition changes

One, or several copies across BI, warehouse, and agent code

Each extra copy is a chance for answers to drift

Model Context Protocol (MCP) is an open protocol, built on JSON-RPC, through which AI applications discover and call tools and read resources exposed by servers [18]. Definitions themselves are also moving toward a shared format: Snowflake, Salesforce, BlackRock, dbt Labs, and RelationalAI announced the Open Semantic Interchange on September 23, 2025, to build a vendor-neutral specification for semantic models [20].

Option

Where definitions live

How an LLM or agent reaches them

How permissions apply

Better fit when

dbt Semantic Layer (MetricFlow)

YAML in the dbt project; MetricFlow is Apache 2.0 from version 0.209.0 [9]

JDBC, GraphQL, and Python SDK [7]; dbt MCP server, local or remote [8]

Check current documentation for per-user row filtering

Your models already live in dbt

Cube

Cube data model

MCP server over HTTPS with OAuth; “every tool runs as the authenticated user” [10]

Existing Cube rules apply to MCP queries [10]

You embed analytics in applications

Snowflake semantic views and Cortex Analyst

Schema-level semantic view objects [11]

Cortex Analyst REST API [12]

Generated SQL runs under Snowflake role-based access control [12]

Most governed data sits in Snowflake

Databricks metric views and Genie

Unity Catalog metric views [14]

Genie Agents, SQL, dashboards [14][15]

Answers governed through Unity Catalog [15]

Most governed data sits in Databricks

Looker (LookML)

LookML model

Conversational Analytics, powered by Gemini [17]

Model and content permissions [17]

LookML is already your BI standard

AtScale

AtScale semantic models, computed in your warehouse [21]

MCP clients such as Claude and ChatGPT [21]

Check current documentation

Many BI tools need one metric source

Text-to-SQL on Raw Tables Versus a Semantic Layer: What Changes?

A semantic layer moves the choice of joins, aggregations, and metric formulas out of the model and into reviewed definitions, and public benchmarks show why that matters: raw-schema SQL generation degrades as schemas start to look like real enterprises. Execution accuracy is the share of generated queries that return the same result as a reference query.

The BIRD benchmark pairs 12,751 questions with SQL across 95 databases. At publication, ChatGPT reached 40.08% execution accuracy against a human baseline of 92.96% [2], and by September 2026 the top entry on the public leaderboard reached 82.95% on the test set, still about ten points below people [3]. Spider 2.0 moved the test to 632 enterprise workflow tasks on databases that often exceed 1,000 columns in BigQuery and Snowflake, and an agent built on o1-preview solved 21.3% of them, against 91.2% on the original Spider [4]. Leaderboard scores have since climbed, but your schema and fiscal calendar were never in either test.

Adding business context changed results sharply in the one controlled study on this question. In a 2023 study over one enterprise SQL database, GPT-4 answered 16% of questions correctly with zero-shot prompts against the tables and 54% when it queried a knowledge graph representation of the same data [5]. The earlier post on the semantic layer that travels with the data makes the full argument.

Decision

Text-to-SQL on raw tables

NLQ through a semantic layer

What “revenue” means

The model infers it from column names

A named, owned metric with one formula

Join paths

The model picks keys, so fan-out double counting is possible

Relationships are declared once

Time grain and fiscal calendar

Guessed from the question

Defined as dimensions

Permissions

Whatever the connection’s account can read

Enforced per user or agent at execution

Reproducibility

A new SQL string per run

The same compiled query per request

Failure visibility

Wrong SQL often runs and returns a plausible number

An unknown metric returns an error or a clarifying question

What Is the Request Flow, Step by Step?

A governed NLQ request runs in seven steps, with identity first, definitions in the middle, and permissions enforced where the query executes.

  1. Authenticate the asker. Attach the identity of the person or agent (and, for an agent, the person it acts for) before anything else happens.

  2. Resolve terms. Match the question’s words to governed metrics, dimensions, and entity values, and ask a clarifying question when two definitions match.

  3. Retrieve context. Pull the matched definitions and verified example queries through the semantic layer’s API or MCP server.

  4. Generate a semantic query. Have the model produce a structured request (metrics, dimensions, filters, time range) instead of free-form SQL.

  5. Compile to SQL. Let the semantic layer’s compiler expand the request into engine-specific SQL with the declared joins and formulas.

  6. Enforce permissions at execution. Run the SQL under the asker’s identity so row filters and column masks apply at the engine.

  7. Return the answer with provenance. Return the number with the definition version, compiled SQL, and sources, and log the request.

Diagram description: a left-to-right flow of seven boxes. A question enters with an identity badge, passes a term resolver linked to a definition store and retrieval index, becomes a structured metric request, compiles to SQL, executes on one or more engines behind a policy check, and returns an answer card listing the definition version and sources, with every box feeding one audit log.

Step

Example: “What was net revenue retention for enterprise accounts in EMEA last quarter?”

1. Authenticate

The request carries the analyst’s identity, which grants EMEA rows only

2. Resolve terms

“Net revenue retention” matches the metric nrr; “enterprise” matches segment = 'Enterprise'; “EMEA” matches the region dimension; “last quarter” resolves to the prior fiscal quarter, which is calendar-shifted

3. Retrieve context

The nrr definition (starting recurring revenue plus expansion, minus contraction and churn, over starting recurring revenue) and a verified query for quarterly NRR

4. Semantic query

metrics: [nrr]; filters: segment, region; grain: fiscal_quarter; range: previous

5. Compile

The compiler writes the SQL, joining subscriptions to accounts on the declared key

6. Enforce

The engine applies the analyst’s row filter, so a question about APAC would return nothing

7. Return

108.4%, with the nrr definition version, the SQL, the fiscal calendar used, and the source tables

The 108.4% in the example is illustrative. Step 2 carries the most ambiguity, because “last quarter” and “enterprise” each have more than one plausible meaning.

How Do You Ground Agents With Retrieval and Entity Resolution?

Ground an agent by retrieving definitions and resolving names to governed identifiers before the query is planned, so retrieval supplies context and the semantic layer supplies the computation. Retrieval-augmented generation (RAG) is a method that pairs a language model with a retriever so generation can draw on documents outside the model’s training data [22]. Entity resolution is the matching of different names or records that refer to the same real-world thing, such as “Acme,” “ACME Corp.,” and a billing account number, to one canonical identifier.

Index what tells the model what things mean (metric and field descriptions, synonyms, glossary entries, values for high-use dimensions, and verified question and SQL pairs) and keep fact rows out. When a question closely matches a stored entry in Snowflake’s Verified Query Repository, Cortex Analyst reuses the vetted SQL [13], and Databricks lets data teams add sample queries and business rules to a Genie Agent [15].

Entity resolution decides whether a filter is right. If “Acme” matches a parent company and two subsidiaries across CRM and billing, the agent should resolve to the canonical customer ID that your master data defines, or ask which one. Clarifying is a reasonable default because it matches how agents already behave: when an agent lacks confidence or authority, 61% of respondents said it escalates to a human and 20% said it proceeds with its best answer (n=202) [1].

  • Store dimension values with their canonical IDs so filters use IDs, not display names.

  • Apply the asker’s permissions to the retrieval index too, or descriptions and values can reveal data the asker cannot query.

  • Refresh the index when definitions change, from the same pipeline that deploys them.

What Are the Failure Modes, and How Do You Prevent Them?

Most NLQ failures produce a plausible number instead of an error, so each failure mode needs a control that either blocks the answer or exposes how it was built. The three that do the most damage are ambiguous metric names, stale definitions, and permission leaks.

Failure mode

What it looks like

Prevention

Ambiguous metric names

“Revenue” matches gross, net, and recognized revenue, and the model picks one silently

Give each metric one owner and a distinct name; require a clarifying question when two match

Stale definitions

The agent uses last year’s churn formula after finance changed it

Deploy definitions from one source and rebuild the retrieval index on every change

Permission leaks

A shared service account returns rows the asker cannot see, or the index exposes sample values

Execute as the asker; filter retrieval by the same policy

Fan-out joins

A one-to-many join double counts revenue

Declare relationships and grain in the semantic layer

Calendar errors

“Q3” resolves to calendar instead of fiscal quarter

Model the fiscal calendar as a dimension

Unanswerable questions answered

No metric exists, so the model composes one

Return “no governed definition” instead of generating SQL

Prompt injection through data

Instructions hidden in a text field steer the agent

Treat retrieved text as data and restrict tool permissions

Stale definitions are a structural risk: in the same survey, 81% of respondents said they must update two or more systems when one business rule changes, and only 11% define it once (n=202) [1]. Permission leaks need explicit design because the MCP specification states that MCP “cannot enforce these security principles at the protocol level,” leaving authorization to implementers [18]. The OWASP Top 10 for LLM Applications lists Sensitive Information Disclosure, Excessive Agency, Misinformation, and Prompt Injection among its 2025 risks [19], and each maps to a row above.

How Do You Test Accuracy?

Test accuracy with a question set that the business owns, with expected results written by metric owners, and run it every time a definition, model, or prompt changes. Public benchmarks measure public schemas, so they cannot tell you whether your agent computes your NRR correctly.

  1. Collect real questions. Pull them from BI requests, tickets, and chat logs, keeping the original wording.

  2. Write expected results. Have each metric owner write the reference SQL or value for a fixed date range.

  3. Include questions that should not be answered. Add ambiguous questions that should get a clarifying question, and out-of-scope or forbidden ones that should get a refusal.

  4. Score by result, not by SQL text. Compare result sets, as Databricks does in Genie benchmarks, where numeric values that agree to four significant digits count as a match [16].

  5. Repeat each question. Run every question several times and count how often the answer changes, which is the consistency gap the survey measured.

  6. Gate deployments. Rerun the set in CI when definitions change, and block the release if accuracy drops in any category.

Category

Example

Pass condition

Direct metric

“Net revenue last month”

Matches the owner’s expected value

Metric plus filter

“Churn for enterprise accounts in EMEA”

Correct value with correct entity IDs

Ambiguous

“How did revenue do?”

Asks which revenue and which period

Out of scope

“Forecast next year’s churn”

States that no governed definition exists

Forbidden

An EMEA analyst asks for APAC detail

Returns no data and logs the attempt

Consistency

Any of the above, asked five times

Same answer every run

Vendors provide parts of this. Genie benchmarks hold up to 500 questions per agent and compare generated results with a reference SQL answer [16], and Cortex Analyst’s verified queries double as a regression set [13].

Why Not Let the Model Write SQL Against Raw Tables?

For analysts exploring a small, well-named schema who can read the SQL before trusting it, direct text-to-SQL is faster to start and often good enough. It needs no modeling work, and current models handle simple joins well. But the answer changes when the reader cannot inspect the SQL: an executive reading a number or an agent acting on one needs the definition to be the same every time, and the benchmark gap on enterprise schemas [4] lands on exactly those users.

Platform choice follows the same logic. If nearly all governed data sits in one warehouse, that platform’s own NLQ feature (Cortex Analyst, Genie, or Looker’s Conversational Analytics) is the simpler fit, with no extra layer to run. A layer across platforms earns its place when one question needs data from several systems or when the same definition must serve several tools and agents. The data contracts guide for AI agents covers how to pin those definitions down between producers and consumers.

How NexusOne Approaches Natural Language Querying Across a Federated Estate

NexusOne runs natural language querying as one governed path across the platforms you already have. Platform-native semantic layers compute inside one platform, but NexusOne is a data and AI control plane that runs across all of them, so one definition can resolve against Apache Iceberg tables, a legacy Hadoop cluster, and cloud warehouses through federated query on Trino, Apache Kyuubi, and Apache Gravitino. The Gravitino catalog exposes the Iceberg REST protocol and federates external catalogs into one namespace, and DataHub holds the metadata and lineage that grounding draws on.

Each question enters the NexusOne AI Data Control Plane with the asker’s identity. One identity and policy model, Keycloak for identity and Apache Ranger for policy, governs people, jobs, and agents, so a query generated for an agent returns only what its principal may see. The control plane screens requests for jailbreaks and PII at the edge, logs allowed and blocked requests with the reasoning, and routes deterministic questions to the query engines at zero tokens before small models and then frontier models. Semantic consistency, entity resolution, and retrieval grounding on your own content sit in that same path. In NexusOne’s view, answering metric questions from governed definitions is where consistency starts, and your own question set is the place to confirm it.

NexusOne’s published deployment model is 5-5-5-5: about 5 minutes to provision, 5 hours to deploy, 5 days to the first governed workload, and 5 weeks to enterprise production, with Embedded Builders working alongside your team. A top-three US bank that ran three legacy Hadoop vendors connected 30 applications in under 4 weeks, eliminating more than $100 million in license and hardware costs. The layer runs identically on-prem, in the cloud, hybrid, or air-gapped on a Kubernetes cluster you control.

To map your definitions and engines onto this path, book an expert consultation.

Key Takeaways

  • Natural language querying works best when the model requests governed metrics and dimensions and the semantic layer compiles the SQL.

  • Raw-schema text-to-SQL drops sharply on enterprise-scale schemas: an o1-preview agent solved 21.3% of Spider 2.0 tasks against 91.2% on the original Spider [4].

  • Enforce identity first and permissions at execution, and apply the same policy to the retrieval index.

  • Resolve business names to canonical IDs, and make clarifying questions the default when two definitions match.

  • Test with a business-owned question set that includes ambiguous, out-of-scope, and forbidden questions, and repeat each question to measure consistency.

  • In NexusOne’s 2026 survey (n=202), 62% saw materially different AI decisions from the same information at least occasionally [1].

Frequently Asked Questions

What Is the Best Enterprise Platform for Enabling Natural Language Querying Through a Unified Business Semantic Layer?

The best platform depends on where your governed data lives. If it sits mostly in one warehouse, that platform’s native option (Snowflake Cortex Analyst, Databricks Genie, or Looker Conversational Analytics) is the simplest fit. If questions span several systems, use a semantic layer that federates across them and enforces each asker’s permissions at execution, which is the approach NexusOne takes.

How Do You Connect a Semantic Layer to an LLM or AI Agent?

Expose the semantic layer through an API or an MCP server, have the model produce a structured request of metrics, dimensions, and filters, and let the semantic layer compile and run the SQL. Pass the asker’s identity on every call so permissions apply at the engine, and return the definition version and SQL with each answer.

Which Data Platforms Are Best for Connecting a Business Semantic Layer to Enterprise LLM and Agent Workflows?

Look for platforms that expose definitions over MCP or a documented API, run queries as the calling user or agent, and ship evaluation tooling. dbt, Cube, and AtScale offer MCP access to their semantic layers, while Snowflake and Databricks expose semantic views and metric views to their own assistants. Cross-platform estates need a layer that reaches every system.

Which Data Platforms Offer the Best Semantic Layer for Contextualizing Business Data for AI Agents?

The strongest options combine governed metric definitions, synonyms and descriptions that help a model match business wording, verified example queries, and permission inheritance. Snowflake semantic views, Databricks metric views, LookML, dbt MetricFlow, Cube, and AtScale each cover these in different ways. Choose by where definitions live and how many systems your agents must query.

How Accurate Is Text-to-SQL Without a Semantic Layer?

Accuracy falls as schemas grow. On the BIRD benchmark, ChatGPT reached 40.08% execution accuracy at publication against 92.96% for people, and an o1-preview agent solved 21.3% of Spider 2.0’s enterprise tasks. In one enterprise study, GPT-4 rose from 16% to 54% correct when given a business-context representation of the same data.

References

  1. More Tools, Less Control: The 2026 State of the Data Estate Report, NexusOne, published September 30, 2026 (survey conducted by Enterprise Management Associates (EMA), September 2026, n=202 data and analytics decision-makers at organizations with 500+ employees in the US, Canada, the UK, and France). https://nexus0ne.substack.com/p/more-tools-less-control-the-2026, retrieved October 20, 2026.

  2. Can LLM Already Serve as A Database Interface? A BIg Bench for Large-Scale Database Grounded Text-to-SQLs (BIRD), Jinyang Li et al., arXiv, May 4, 2023 (v3 November 15, 2023). https://arxiv.org/abs/2305.03111, retrieved October 20, 2026.

  3. BIRD-SQL Leaderboard, BIRD benchmark team. https://bird-bench.github.io/, retrieved October 20, 2026.

  4. Spider 2.0: Evaluating Language Models on Real-World Enterprise Text-to-SQL Workflows, Fangyu Lei et al., ICLR 2025, arXiv, November 12, 2024 (revised March 17, 2025). https://arxiv.org/abs/2411.07763, retrieved October 20, 2026.

  5. A Benchmark to Understand the Role of Knowledge Graphs on Large Language Model’s Accuracy for Question Answering on Enterprise SQL Databases, Juan Sequeda, Dean Allemang, Bryon Jacob, arXiv, November 13, 2023. https://arxiv.org/abs/2311.07509, retrieved October 20, 2026.

  6. dbt Semantic Layer, dbt Labs Documentation. https://docs.getdbt.com/docs/use-dbt-semantic-layer/dbt-sl, retrieved October 20, 2026.

  7. Semantic Layer APIs (GraphQL, JDBC, Python SDK), dbt Labs Documentation. https://docs.getdbt.com/docs/dbt-apis/sl-api-overview, retrieved October 20, 2026.

  8. About dbt MCP server, dbt Labs Documentation. https://docs.getdbt.com/docs/dbt-ai/about-mcp, retrieved October 20, 2026.

  9. MetricFlow repository and license, dbt Labs, GitHub. https://github.com/dbt-labs/metricflow, retrieved October 20, 2026.

  10. MCP server, Cube Documentation. https://docs.cube.dev/docs/integrations/mcp-server, retrieved October 20, 2026.

  11. Overview of semantic views, Snowflake Documentation. https://docs.snowflake.com/en/user-guide/views-semantic/overview, retrieved October 20, 2026.

  12. Cortex Analyst, Snowflake Documentation. https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-analyst, retrieved October 20, 2026.

  13. Cortex Analyst Verified Query Repository, Snowflake Documentation. https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-analyst/verified-query-repository, retrieved October 20, 2026.

  14. Unity Catalog metric views, Databricks Documentation, last updated September 11, 2026. https://docs.databricks.com/aws/en/metric-views/, retrieved October 20, 2026.

  15. Genie, Databricks Documentation. https://docs.databricks.com/aws/en/genie/, retrieved October 20, 2026.

  16. Use benchmarks in a Genie Agent, Databricks Documentation. https://docs.databricks.com/aws/en/genie/benchmarks, retrieved October 20, 2026.

  17. Conversational Analytics in Looker overview, Google Cloud Documentation. https://docs.cloud.google.com/looker/docs/conversational-analytics-overview, retrieved October 20, 2026.

  18. Model Context Protocol Specification (2025-06-18), Model Context Protocol. https://modelcontextprotocol.io/specification/2025-06-18, retrieved October 20, 2026.

  19. OWASP Top 10 for LLM Applications 2025, OWASP GenAI Security Project. https://genai.owasp.org/llm-top-10/, retrieved October 20, 2026.

  20. Open Semantic Interchange initiative announcement, Snowflake, September 23, 2025. https://www.snowflake.com/en/news/press-releases/snowflake-salesforce-dbt-labs-and-more-revolutionize-data-readiness-for-ai-with-open-semantic-interchange-initiative/, retrieved October 20, 2026.

  21. AtScale Universal Semantic Layer, AtScale. https://www.atscale.com/, retrieved October 20, 2026.

  22. Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, Patrick Lewis et al., arXiv, May 2020. https://arxiv.org/abs/2005.11401, retrieved October 20, 2026.

ABOUT

1115 Howell Mill Rd
Suite 430,
Atlanta, GA 30318
An Insight Partners Company


Product Updates and News

@2026 NexusOne® - All rights reserved.

ABOUT

1115 Howell Mill Rd
Suite 430,
Atlanta, GA 30318
An Insight Partners Company


Product Updates and News

@2026 NexusOne® - All rights reserved.

ABOUT

1115 Howell Mill Rd
Suite 430,
Atlanta, GA 30318
An Insight Partners Company


Product Updates and News

@2026 NexusOne® - All rights reserved.