Built with Tutify.io

    AIStudyLabs

    Context Layer vs Semantic Layer: Differences and When You Need Each

    Context Layer vs Semantic Layer: Differences and When You Need Each

    If you already run a semantic layer, the first time someone pitches you a "context layer" you'll probably wonder whether you're being sold the same thing twice. It's a fair question. The context layer vs semantic layer debate is mostly happening on vendor blogs, and each vendor draws the line where its own product ends.

    This article separates the two. It covers what a semantic layer does well, what it was never designed to do, what the published benchmarks say about accuracy, and how to decide whether you need more than the semantic layer you have. If you're new to the overall idea, start with the series overview on what a context layer is and come back here.

    What a semantic layer does

    A semantic layer maps business concepts to the SQL that computes them. You define a metric once ("net revenue is the sum of order amount minus refunds, excluding intercompany orders"), declare the dimensions it can be grouped by and the joins between tables, and every tool that asks for net revenue gets the same query.

    The idea goes back to the 1990s, when BI tools such as BusinessObjects and OLAP cubes put a business-friendly layer over databases. What changed in the last few years is that semantic layers moved into code. dbt's MetricFlow, Cube, AtScale, LookML and Snowflake's semantic views all store definitions as text files or DDL that you version, review and test like any other code.

    Three properties make a semantic layer useful:

    What a context layer adds

    A context layer covers everything an AI agent needs to use data correctly, not only the metric math. Vendor lists vary, but the extras usually include:

    Decube frames the split as two questions. The semantic layer answers "what does this metric mean?" The context layer answers when, how and under what rules an agent can use it.

    Diagram showing the semantic layer inside the context layer: metrics, dimensions and joins compile SQL against the warehouse, while lineage, policies, glossary, documents and memory surround it, and AI agents and BI tools sit on top

    How do the context layer and semantic layer relate? Four vendor views

    Here's where the published opinions split. All of these come from companies selling one side or the other, so read them as positions, not findings.

    | Source | View | What it implies | |---|---|---| | Cube | The context layer is a superset, and the semantic layer is "the one part that actually executes" | Don't build a context layer without a semantic core | | Atlan | The semantic layer is the substrate inside an operational shell of governance and lineage | The catalog is the centre of gravity | | Decube | The semantic layer is an input the context layer consumes and enriches | Metadata tooling wraps your metrics | | Contextual AI | They sit at different points: semantic layer for structured SQL data, context layer for everything including documents | Choose by data type |

    Despite the different framing, three of the four agree on the structure: the context layer contains or consumes the semantic layer. None of them argues that a context layer replaces it. Cube's CEO put it this way in July 2026: "the semantic layer sits inside it as the one part that actually executes."

    Contextual AI's view is the odd one out, and it's useful for a different reason. It points out that "a semantic layer cannot process a 200-page engineering specification." If your agent's hard questions live in documents, a semantic layer won't help, however good it is.

    Context layer vs semantic layer at a glance

    | | Semantic layer | Context layer | |---|---|---| | Core question | What does this metric mean? | When, how and under what rules can an agent use it? | | Main consumer | BI tools and analysts, now agents too | AI agents | | Contents | Metrics, dimensions, entities, joins | Semantic definitions plus lineage, policies, glossary, quality, documents, memory | | Data scope | Structured warehouse data | Structured and unstructured | | Runs queries? | Yes, compiles governed SQL | Mostly descriptive, relies on the semantic layer to execute | | Typical failure | An error when a question is out of scope | Agent uses deprecated or unauthorized data | | Maintained by | Analytics engineers, in code | Data owners and stewards, continuously | | Examples | dbt MetricFlow, Cube, AtScale, LookML, Snowflake semantic views | Catalog platforms with agent access, Snowflake Horizon Context, Microsoft Fabric IQ |

    The two platform products in the last row bundle both layers. If you're evaluating them, the series has a direct comparison of Snowflake Horizon Context and Microsoft Fabric IQ.

    What the accuracy benchmarks show

    The strongest argument for a semantic layer in AI work is accuracy on text-to-SQL questions. Two studies get cited most, and both need context.

    data.world, 2023. Sequeda, Allemang and Jacob tested GPT-4 on an insurance schema. Asked to write SQL directly, it answered 16.7% of questions correctly. Given a knowledge graph representation of the same data, it reached 54.2%. On the hardest questions, plain SQL scored 0% and the graph scored 38.7%. These numbers are from 2023-era models and are often quoted as if they still held. They don't.

    dbt Labs, 2026. dbt Labs reran a version of that benchmark in April 2026 on a properly modeled dbt project, with 11 questions and 20 runs each. Claude Sonnet 4.6 scored 90.0% writing SQL directly and 98.2% through the semantic layer. GPT-5.3-Codex scored 84.1% and 100%.

    Two details from the dbt study matter more than the headline. First, when a question fell outside what the semantic layer modeled, it returned an error instead of a plausible wrong number. For an agent, that's the behaviour you want. Second, dbt's write-up notes that good data modeling helped both approaches, so part of the gain came from clean models rather than from the layer itself.

    The caveats are real: 11 questions, one dataset, and a vendor running the test. It's still the most recent public test of this question.

    When a semantic layer alone is enough

    You don't need a full context layer for every AI use case. A semantic layer on its own covers you when:

    That covers a lot of real deployments: governed self-service BI, board reporting assistants, and "ask your dashboard" features. If that's your scope, invest in metric modeling first and skip the rest.

    You'll want the wider context layer when agents need to read documents, respect PII and certification flags, explain lineage, remember past decisions, or act across several systems. At that point the context layer vs semantic layer question stops being either-or: you need both, with the semantic layer as the executable core.

    Common mistakes in the context layer vs semantic layer decision

    Buying a context layer to avoid modeling. If your metrics aren't defined, a catalog full of descriptions won't save you. The agent still has to compute the number somewhere, and without a semantic layer it writes its own SQL.

    Treating catalog descriptions as metric definitions. A description that says "revenue, see finance" is documentation. A metric that compiles to SQL is a definition. Agents need the second.

    Quoting 2023 benchmarks as current. Models have improved. Use recent numbers and say how they were measured.

    Ignoring scope errors. A semantic layer that refuses out-of-scope questions is doing its job. Don't "fix" that by letting the agent fall back to raw SQL without telling the user.

    Locking definitions into one tool. Keep them in code so they can move between tools.

    Is a metrics layer the same thing?

    Mostly, yes, with one difference worth knowing. The metrics layer label came from a wave of tools that focused on metric definitions alone: name, aggregation, time grain and filters. Joins and entities were handled elsewhere, usually in the BI tool. As those products matured, they added entities and joins, and the broader name took over.

    If a vendor today calls its product a metrics layer, ask two questions. Can it join across tables using declared relationships, or do you have to pre-join everything into wide tables? And can an agent query it through an API or the Model Context Protocol (MCP), or only through a BI front end? A metrics layer that answers yes to both does the job described in this article, whatever it's called.

    A quick test for your own stack

    Before deciding anything, run this check with the tools you already have. Take ten real questions from users, the kind an agent would get. For each one, write down:

    1. Can it be answered with SQL over warehouse tables?
    2. Is there one agreed definition for every term in it?
    3. Does answering it need anything outside the warehouse, such as a document, a policy or a past decision?
    4. Would a wrong answer cause harm, or just mild embarrassment?

    If most questions are answerable with SQL and agreed definitions, your priority is modeling metrics well. If many need documents, policies or history, or if wrong answers are costly, plan for the wider context layer from the start.

    Open Semantic Interchange and portability

    Every platform now has its own metric format, and that's a problem if you use more than one. The Open Semantic Interchange initiative, launched in September 2025 by Snowflake, Salesforce, dbt Labs, RelationalAI and BlackRock with 17 launch partners, set out to define one vendor-neutral spec for datasets, metrics, dimensions and relationships. The spec was published under Apache 2.0 in January 2026, and in July 2026 the project entered the Apache Incubator as Apache Ossie.

    dbt Labs also open-sourced MetricFlow under Apache 2.0 in October 2025 as part of that commitment, so older articles describing it as source-available are out of date.

    For the semantic layer, this means definitions written today have a better chance of moving between tools later. For the wider context layer, there's no equivalent standard yet. Lineage has OpenLineage, and delivery to agents has the Model Context Protocol, but policies and memory are still vendor-specific.

    How agents reach each layer

    Both layers are increasingly served to agents over MCP. A semantic layer exposes tools such as list_metrics and query_metrics. A catalog exposes search and get_lineage. If you haven't worked with the protocol, how the Model Context Protocol works covers the basics with a Python example, and the hands-on guide to querying the dbt Semantic Layer from an AI agent shows the semantic tools in use.

    What the agent does with those tool results inside its context window is a separate problem. Pulling every metric definition into the prompt wastes tokens and confuses the model. The article on context engineering for AI agents covers how to select and compress what the agent sees.

    Relationships beyond simple joins, such as supply chains or org hierarchies, often push teams toward a graph. The difference between a taxonomy, an ontology and a knowledge graph is covered in our ontology series, and knowledge graphs for AI agents looks at when that extra structure pays for itself.

    A practical order of work

    If you're starting from nothing, this sequence avoids most wasted effort:

    1. Define the small set of metrics your first AI use case needs, in code.
    2. Test them against a set of real questions with known answers.
    3. Add certification flags and owners for the tables behind those metrics.
    4. Add access policies that follow the user, not a shared service account.
    5. Only then add lineage, documents and memory, as the use case needs them.

    The full version of this plan, with open-source options at each step, is in how to build a context layer for AI.

    Key takeaways