A semantic layer is the governed set of metric definitions, dimensions and relationships that sits between your data and the tools that query it, so every dashboard and AI agent computes a term such as revenue the same way, instead of each team writing its own formula.

What goes into a semantic layer

A semantic layer is not a copy of your warehouse. It is the business language an analyst or an agent uses when they ask for a metric, and the logic that turns that request into the right tables, joins and filters.

  • Metric definitions. The agreed formula for a term such as revenue or active users, including the grain and the default filters, written once.
  • Dimensions. The attributes you slice by, such as region, product or customer type, so the same cut is available in every tool.
  • Relationships. How those metrics and dimensions join, so a question does not depend on each analyst reinventing the path through the warehouse.
  • Filters and business rules. The constraints that belong on the metric itself, for example excluding test accounts, rather than sitting in one dashboard's WHERE clause.
  • Access rules. Who may see which rows or fields, so a BI tool and an agent apply the same policy.

Those definitions often already live in tools such as dbt, Looker, Snowflake, Databricks or Tableau. The semantic layer is the shared contract those tools, and now agents, are supposed to honor.

Why teams use a semantic layer

When two dashboards disagree on revenue, the argument is usually not about the warehouse. It is about two formulas, maintained in two places, that drifted apart. A semantic layer puts the formula in one place so Looker, a notebook and a text-to-SQL agent can reuse it.

That is also why a semantic layer is useful before you add more BI tools, or before you let an agent answer questions on its own. The layer does not invent a new number. It stops each consumer from inventing its own.

Why AI agents need a semantic layer

Ask an analytics agent for last quarter's net revenue and it will look for a column or a calculation that fits the question. If one pipeline computes net_revenue with refunds removed and another does not, the agent can pick either one. The answer looks confident. It is still the wrong definition.

A semantic layer gives the agent the agreed formula, at the agreed grain, with the filters the business already approved. It does not, on its own, tell the agent which table is stale, who may see the data, or how the rest of the business ontology is defined. That wider meaning is what context for AI agents is, and it usually lives in a context layer around the semantic layer, not instead of it.

How a semantic layer differs from a context layer

A semantic layer defines metrics once so every query uses the same formula. A context layer usually includes those definitions and adds meaning, ownership, freshness, access rules and lineage for the rest of the data an agent might use.

The side-by-side comparison, including how a code and data graph differs from both, stays on the context layer vs semantic layer page. The definition of a context layer is on its own ontology page.

How to build a semantic layer

Start from the metrics people already argue about, not from a complete model of the business. Write each formula once, with its grain, filters and owner, in the tool where your transformations already live, for example dbt, or in the BI model your analysts already use.

Expose those definitions to every dashboard, notebook and agent that needs them, through the same interface, so a new tool does not get a second copy of the logic. Then keep the definitions current as the underlying tables and the code that writes them change. A definition that no longer matches the columns behind it is how two "official" numbers appear again.

How Foundational keeps metric definitions tied to the code that produces them

A semantic layer is only as trustworthy as the columns underneath it. Catalog or warehouse metadata can describe a Snowflake or Databricks table and still miss the Java or Python service that calculates the number a metric depends on. When that code changes, the formula in dbt or Looker can look the same and still be wrong.

Foundational is a data & AI governance platform that statically analyzes your code to build a data flow graph. The graph follows data from application code and pipelines through the warehouse to BI tools, so you can see which code produces the columns behind a metric, and what a change will affect, before it ships. Foundational does this without accessing your data. The analysis covers application languages such as Java, Python, TypeScript, Go and SQL, not only pipelines. It does not replace your semantic layer. It keeps that layer honest as the code changes, and it gives AI agents the lineage and code context those metric definitions sit on.

Semantic layer FAQ

What is a semantic layer?

A semantic layer is the governed set of metric definitions, dimensions and relationships that sits between your data and the tools that query it, so every dashboard and AI agent computes a term such as revenue the same way, instead of each team writing its own formula.

It usually lives in a transformation tool or a BI model, for example dbt or Looker, and is queried by dashboards, notebooks and agents. It is not a second copy of the warehouse, and it is not a full context layer.

What is a semantic layer for AI?

A semantic layer for AI is that same layer used by agents, not only by dashboards. It gives an analytics or text-to-SQL agent the approved formula, grain and filters for a metric, so the agent does not guess at a similarly named column.

The agent still needs more than a metric formula: which data it may see, whether that data is current, and how the business ontology defines the term. Those sit in a context layer around the semantic layer.

Is a semantic layer the same as a data catalog?

No. A catalog describes tables, columns, owners and often lineage. A semantic layer defines how a metric is calculated from those tables, and how it may be sliced.

Teams often use both. The catalog is where people find and trust the datasets. The semantic layer is where a dashboard or an agent goes to compute an approved number. A short contrast with a context layer, which packages catalog metadata and metric definitions for an agent, is on the context layer vs semantic layer page.

How is a semantic layer different from a context layer?

They are not the same. A semantic layer defines metrics once so every query uses the same formula. A context layer usually includes those definitions and adds meaning, ownership, freshness, access rules and lineage for the rest of the data an agent might use.

The full comparison, including how a code and data graph differs from both, is on the context layer vs semantic layer page.

Do I still need a semantic layer if I already have a context layer?

Yes, if you want one official formula for each metric. A context layer can include those definitions, but it does not invent them. Someone still has to write the metric logic, usually in dbt, Looker or a warehouse semantic model, and keep it current.

If you skip the semantic layer, an agent can read descriptions and owners and still pick the wrong calculation. Keep the official formula in the semantic layer, and keep the broader meaning in the context layer.

Related terms

Context layer · Data lineage · Data catalog

code snippet <goes here>
<style>.horizontal-trigger {height: calc(100% - 100vh);}</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.8.0/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.8.0/ScrollTrigger.min.js"></script>
<script>
// © Code by T.RICKS, https://www.timothyricks.com/
// Copyright 2021, T.RICKS, All rights reserved.
// You have the license to use this code in your projects but not to redistribute it to others
gsap.registerPlugin(ScrollTrigger);
let horizontalItem = $(".horizontal-item");
let horizontalSection = $(".horizontal-section");
let moveDistance;
function calculateScroll() {
 // Desktop
 let itemsInView = 3;
 let scrollSpeed = 1.2;  if (window.matchMedia("(max-width: 479px)").matches) {
   // Mobile Portrait
   itemsInView = 1;
   scrollSpeed = 1.2;
 } else if (window.matchMedia("(max-width: 767px)").matches) {
   // Mobile Landscape
   itemsInView = 1;
   scrollSpeed = 1.2;
 } else if (window.matchMedia("(max-width: 991px)").matches) {
   // Tablet
   itemsInView = 2;
   scrollSpeed = 1.2;
 }
 let moveAmount = horizontalItem.length - itemsInView;
 let minHeight =
   scrollSpeed * horizontalItem.outerWidth() * horizontalItem.length;
 if (moveAmount <= 0) {
   moveAmount = 0;
   minHeight = 0;
   // horizontalSection.css('height', '100vh');
 } else {
   horizontalSection.css("height", "200vh");
 }
 moveDistance = horizontalItem.outerWidth() * moveAmount;
 horizontalSection.css("min-height", minHeight + "px");
}
calculateScroll();
window.onresize = function () {
 calculateScroll();
};let tl = gsap.timeline({
 scrollTrigger: {
   trigger: ".horizontal-trigger",
   // trigger element - viewport
   start: "top top",
   end: "bottom top",
   invalidateOnRefresh: true,
   scrub: 1
 }
});
tl.to(".horizontal-section .list", {
 x: () => -moveDistance,
 duration: 1
});
</script>

Keep Metric Definitions Tied to the Code That Produces Them

Request a demo to see how Foundational shows which code produces the columns behind a metric, and what a change will affect.

Keep Metric Definitions Tied to the Code That Produces Them

Request a demo to see how Foundational shows which code produces the columns behind a metric, and what a change will affect.

Keep Metric Definitions Tied to the Code That Produces Them

Request a demo to see how Foundational shows which code produces the columns behind a metric, and what a change will affect.

Share this post

Governance that starts at the source.