Semantic Layer
A semantic layer defines metrics, dimensions and joins once in code, so every BI tool and AI agent uses the same definition of each metric.
What Is a Semantic Layer?
A semantic layer is a set of shared definitions for metrics, dimensions and joins that sits between the data warehouse and every tool that queries it. Each metric, such as net revenue or weekly active users, is written once in code, and BI tools, notebooks and AI agents request it by name instead of rewriting the SQL.
The layer stores three kinds of definitions:
- Measures and metrics: the aggregation and its filters, such as
SUM(amount)counted only for paid rows. - Dimensions: the attributes a metric can be grouped or filtered by, such as region, plan, or order date at day, week or month grain.
- Entities and joins: how tables relate, so
ordersjoinscustomerson the same key in every query.
How a Semantic Layer Works
A semantic layer compiles a metric request into warehouse SQL at query time. A request for net_revenue by region resolves to the stored definition, joins and filters, and the layer sends generated SQL to Snowflake, BigQuery, Redshift or Databricks. The warehouse does the compute, which fits the ELT pattern of transforming data after it lands.
One metric, two dashboards
Without a shared definition, two teams write net revenue differently. The finance dashboard:
SELECT date_trunc('month', o.created_at) AS month,
SUM(o.amount - COALESCE(r.amount, 0)) AS net_revenue
FROM orders o
LEFT JOIN refunds r ON r.order_id = o.id
WHERE o.status = 'paid'
GROUP BY 1;The growth dashboard:
SELECT date_trunc('month', o.paid_at) AS month,
SUM(o.amount) - SUM(o.discount) AS net_revenue
FROM orders o
WHERE o.status IN ('paid', 'partially_refunded')
GROUP BY 1;Both charts are labeled "Net revenue" and disagree on four points:
- Date column:
created_atvspaid_at, so an order placed on the 31st and paid on the 1st lands in different months. - Deductions: refunds in one query, discounts in the other.
- Status filter: partially refunded orders count in only one.
- Join fan-out: the finance query counts
o.amounttwice when an order has two refund rows.
The same metric, defined once
In the dbt Semantic Layer, the definition lives in the model's YAML, which MetricFlow, dbt's open-source query engine, compiles to SQL:
models:
- name: orders
semantic_model:
enabled: true
agg_time_dimension: paid_at
columns:
- name: order_id
entity:
name: order_id
type: primary
- name: paid_at
granularity: day
dimension:
type: time
- name: status
dimension:
type: categorical
metrics:
- name: net_revenue
label: Net revenue
type: simple
agg: sum
expr: amount - discount - refunded_amount
filter: |
{{ Dimension('order_id__status') }} in ('paid', 'partially_refunded')Both dashboards now request net_revenue by metric_time__month. The refund total is precomputed per order in the orders model, so the metric needs no refunds join, and changing the rule takes one pull request.
Types of Semantic Layers
Semantic layers fall into three groups by where the definitions live. As of December 2026:
| Type | Examples | Where definitions live | Who can query them | Trade-off |
|---|---|---|---|---|
| BI-embedded | LookML (Looker), Power BI semantic models | The BI tool's project files | Mainly that BI tool | Mature and tightly integrated; hard to reuse outside the tool |
| Standalone | dbt Semantic Layer, Cube, AtScale | YAML or code in a dbt project or a separate service | Clients that support its APIs, such as SQL or GraphQL | Works across tools; one more service to run and debug |
| Warehouse-native | Snowflake semantic views, Databricks metric views | Objects in the warehouse catalog | Anything connected to that warehouse | No extra service; definitions tied to one platform |
- MetricFlow moved to the Apache 2.0 license in October 2025, after earlier AGPL and BSL releases (dbt Labs, license history).
- Cube exposes a Postgres-compatible SQL API next to REST and GraphQL, and serves repeat queries from pre-aggregations, rollup tables kept in Cube Store (Cube docs).
- Snowflake semantic views are schema-level objects queried with the
SEMANTIC_VIEWclause or a standardSELECT(Snowflake), and Cortex Analyst reads them to generate SQL (release notes). - Databricks metric views live in Unity Catalog and are written in YAML (Databricks).
- Apache Ossie (incubating), formerly Open Semantic Interchange, is a vendor-neutral YAML spec for metrics, dimensions and joins that entered the Apache Incubator in June 2026 (Apache Ossie).
When to use which: stay BI-embedded if one BI tool serves every consumer, go standalone when several tools and agents need the same metrics, and go warehouse-native when one platform holds all the data.
What a Semantic Layer Does Not Hold
A semantic layer stores the math and the dimensions but cannot tell whether the tables beneath a metric are the right ones, current or intact:
- Which table is canonical. When
orders,orders_v2andstg_ordersall exist, the model points at one, and nothing in the layer marks the other two as deprecated. That belongs in a data catalog. - Freshness.
net_revenuereturns a number whetherordersloaded 30 seconds ago or yesterday. Freshness comes from the pipeline feeding the warehouse, as covered in what a real-time data warehouse is. - Provenance. Which Postgres column became
amount, and which transforms touched it, is data lineage. - Source schema changes. A column renamed in the application database breaks the definition, sometimes without an error: if the pipeline keeps the old column, as many CDC pipelines do by default, it stops filling and the metric goes quietly wrong. Snowflake schema evolution covers how those changes arrive.
These facts make up what is often called a context layer.
Semantic Layer Best Practices
A semantic layer pays off when a small set of high-stakes metrics is defined, owned and tested like application code.
- Start with the metrics leadership sees. Revenue, active users and churn cause the most disagreement.
- Give each metric an owner who reviews every change to its definition.
- Validate in CI. Run
dbt sl validateor MetricFlow'smf validate-configson each pull request, and compare outputs against known totals for a closed period. - Delete the old SQL. Repoint dashboards at the layer and remove hand-written metric queries, or drift returns.
- Write descriptions for agents. LLMs pick metrics by name and description, so state units, currency, time zone and exclusions in the definition.
- Watch the source schema for renames and type changes before they reach the warehouse model.
How Artie handles this
Artie sits under the semantic layer and supplies part of that context. It replicates source databases into the warehouse with change data capture. Each pipeline maps a source table to a warehouse table, so Artie knows where each table comes from and how far it lags the source. Every weekday morning by default, it also checks the source databases of running pipelines for added, removed and altered columns. Artie does not define metrics.
In Artie's Data Catalog, your team marks tables as certified or deprecated. It also shows which warehouse tables are built from which.
Frequently asked questions
What is a semantic layer?
A semantic layer is a shared, code-defined set of metrics, dimensions and join paths that compiles each request into warehouse SQL. It gives BI tools, notebooks and AI agents one definition per metric, so net revenue returns the same number in every dashboard that asks for it.
Is a semantic layer the same as a metrics layer?
A metrics layer is the narrower term for the part of a semantic layer that defines metrics. A semantic layer also models dimensions, entities and the joins between tables. Most vendors now use "semantic layer" for the whole model, and many engineers treat the two terms as interchangeable.
Do AI agents need a semantic layer to write correct SQL?
AI agents produce more consistent SQL with a semantic layer because they request a named metric instead of inferring joins and filters from raw schemas. The layer does not tell an agent which table is current or trusted, so agents still need catalog, lineage and freshness metadata next to it.
Does a semantic layer fix stale or wrong source data?
A semantic layer does not fix stale or wrong data. It applies the same calculation to whatever the warehouse holds, so a delayed pipeline or a broken source column yields a consistently wrong number. Freshness and correctness come from the ingestion pipeline and from data quality checks upstream of the layer.