> Markdown version of https://www.artie.com/glossary/semantic-layer. Site index for AI agents: https://www.artie.com/llms.txt

[Back to glossary](https://www.artie.com/glossary)

# 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.

[Share on LinkedIn (opens in a new tab)](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fwww.artie.com%2Fglossary%2Fsemantic-layer) [Share on X (opens in a new tab)](https://x.com/intent/post?text=Semantic%20Layer\&url=https%3A%2F%2Fwww.artie.com%2Fglossary%2Fsemantic-layer)

## 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 `orders` joins `customers` on 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](https://www.artie.com/blogs/why-elts-are-here-to-stay) of transforming data after it lands.

### One metric, two dashboards

Without a shared definition, two teams write net revenue differently. The finance dashboard:

SQL

```
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:

SQL

```
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_at` vs `paid_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.amount` twice 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:

YAML

```
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](https://www.getdbt.com/blog/dbt-labs-affirms-commitment-to-open-semantic-interchange-by-open-sourcing-metricflow), [license history](https://github.com/dbt-labs/metricflow#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](https://docs.cube.dev/docs/introduction)).
* **Snowflake semantic views** are schema-level objects queried with the `SEMANTIC_VIEW` clause or a standard `SELECT` ([Snowflake](https://docs.snowflake.com/en/user-guide/views-semantic/querying)), and Cortex Analyst reads them to generate SQL ([release notes](https://docs.snowflake.com/en/release-notes/2025/june-summit)).
* **Databricks metric views** live in Unity Catalog and are written in YAML ([Databricks](https://docs.databricks.com/aws/en/uc-semantics/metric-views)).
* **Apache Ossie (incubating)**, formerly Open Semantic Interchange, is a vendor-neutral YAML spec for metrics, dimensions and joins that entered the [Apache Incubator](https://incubator.apache.org/projects/ossie.html) in June 2026 ([Apache Ossie](https://ossie.apache.org/)).

**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_v2` and `stg_orders` all 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_revenue` returns a number whether `orders` loaded 30 seconds ago or yesterday. Freshness comes from the pipeline feeding the warehouse, as covered in [what a real-time data warehouse is](https://www.artie.com/blogs/what-is-a-real-time-data-warehouse).
* **Provenance.** Which Postgres column became `amount`, and which transforms touched it, is [data lineage](https://www.artie.com/glossary/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](https://www.artie.com/blogs/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 validate` or MetricFlow's `mf validate-configs` on 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](https://www.artie.com/glossary/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](https://www.artie.com/docs/monitoring/schema-changes) 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.

## Related resources

* [Glossary term](https://www.artie.com/glossary/change-data-capture)
  ### [Change Data Capture](https://www.artie.com/glossary/change-data-capture)
* [Glossary term](https://www.artie.com/glossary/data-lineage)
  ### [Data Lineage](https://www.artie.com/glossary/data-lineage)
* [Glossary term](https://www.artie.com/glossary/real-time-data-warehouse)
  ### [Real-Time Data Warehouse](https://www.artie.com/glossary/real-time-data-warehouse)
* [Blog post](https://www.artie.com/blogs/why-elts-are-here-to-stay)
  ### [Why ELTs are here to stay](https://www.artie.com/blogs/why-elts-are-here-to-stay)
* [Blog post](https://www.artie.com/blogs/improve-data-quality-with-in-flight-data-pipeline-validation)
  ### [Improve data quality with in-flight data pipeline validation](https://www.artie.com/blogs/improve-data-quality-with-in-flight-data-pipeline-validation)
* [Blog post](https://www.artie.com/blogs/snowflake-schema-evolution)
  ### [Snowflake schema evolution](https://www.artie.com/blogs/snowflake-schema-evolution)

## Watch your data replicate live

[Start for free](https://app.artie.com/signup) [Book a demo](https://www.artie.com/contact)
