What is a semantic layer? A plain answer with an example

The definition in one sentence, a worked revenue metric that returns three different numbers without one, what breaks, and when a team genuinely does not need a semantic layer yet.

A semantic layer is a set of shared, version-controlled definitions (metrics, dimensions, join paths and access rules) that sits between your warehouse and every tool that queries it, and turns a business question like “net revenue by country, monthly” into SQL. Instead of each dashboard, notebook and AI assistant writing its own SUM(...) with its own filters, they all ask the semantic layer, and it generates the same SQL every time. The idea is old: Google describes LookML as “the language that is used in Looker to create semantic data models”, and Microsoft renamed Power BI datasets to semantic models. What changed recently is where the layer lives. The dbt Semantic Layer moves metric definitions “out of the BI layer and into the modeling layer”, and Snowflake and Databricks now store them as warehouse objects. Below: what a semantic layer contains, a worked example run on ClickHouse 26.9, what breaks without one, and when you can skip it.

What does a semantic layer contain?

Every implementation spells it differently, but the parts are the same. If you know these six, you can read LookML, a dbt semantic model, a Cube data model or a Snowflake semantic view.

PartWhat it isExample
Entity (or logical table)A business object mapped to a physical table, with its keyorder maps to marts.fct_orders, key order_id
DimensionAn attribute you group or filter bycountry, plan, ordered_at
MeasureA raw aggregation over a columnsum(amount_eur - refunded_eur)
MetricA named, agreed business number built from measures, with its filtersnet_revenue: paid, non-test orders, net of refunds
Relationship (join path)How entities connect, and in which directionorder.customer_id to customer.customer_id, many-to-one
Access ruleWho may see which rows or metricsCountry managers see only their country

Two properties make this a semantic layer rather than a folder of saved queries. First, the definitions are declarative: you say what net_revenue means, not which SQL to run for each chart. Second, there is a compiler: given a metric, a set of dimensions, a time grain and filters, it writes the SQL, including the joins. That is why one definition can serve hundreds of different charts.

A worked example: one revenue number, three answers

Here is a small orders table. It is deliberately ordinary: a status column, a test-account flag, partial refunds and UTC timestamps.

CREATE TABLE orders
(
    order_id     UInt64,
    customer_id  UInt64,
    country      LowCardinality(String),
    status       LowCardinality(String),   -- 'paid' | 'cancelled'
    is_test      UInt8,
    amount_eur   Decimal(12, 2),
    refunded_eur Decimal(12, 2),
    ordered_at   DateTime('UTC')
)
ENGINE = MergeTree
ORDER BY (ordered_at, order_id);

INSERT INTO orders VALUES
    (1, 101, 'DE', 'paid',      0, 120.00,  0.00, '2026-09-03 10:00:00'),
    (2, 102, 'DE', 'paid',      0,  80.00, 30.00, '2026-09-14 16:20:00'),
    (3, 103, 'FR', 'cancelled', 0, 200.00,  0.00, '2026-09-20 09:05:00'),
    (4, 104, 'FR', 'paid',      0, 150.00,  0.00, '2026-09-30 22:30:00'),
    (5, 999, 'DE', 'paid',      1, 500.00,  0.00, '2026-09-22 12:00:00'),
    (6, 105, 'FR', 'paid',      0,  60.00,  0.00, '2026-10-02 08:15:00');

Someone asks “what was revenue in September?”. The finance dashboard was built quickly and sums everything in the month:

SELECT sum(amount_eur) AS revenue
FROM orders
WHERE ordered_at >= '2026-09-01' AND ordered_at < '2026-10-01';
-- 1050

An analyst in a European office writes a more careful query. It excludes cancelled and test orders, nets refunds, and buckets months in the local time zone:

SELECT sum(amount_eur - refunded_eur) AS revenue
FROM orders
WHERE status = 'paid'
  AND is_test = 0
  AND toStartOfMonth(ordered_at, 'Europe/Berlin') = '2026-09-01';
-- 170

The analyst’s 170 drops order 4, placed at 22:30 UTC on 30 September, which is already 1 October in Berlin. A third person applies the analyst’s filters but uses UTC months and gets 320. All three ran on ClickHouse 26.9 against the same six rows. Each query is defensible on its own; none of them is wrong SQL. The number is wrong because “revenue” was never defined, so every author defined it in passing, inside a WHERE clause nobody else reads.

This is the problem a semantic layer solves. The disagreement is not about SQL skill. It is about four business decisions (cancelled orders, test accounts, refunds, time zone) that someone has to make once and write down where every query will pick them up. We go deeper on how to find these splits in an existing stack in the metric drift audit.

What does the definition look like?

In a semantic layer, those four decisions become one entry. The YAML below is a generic shape; dbt, Cube, LookML and Snowflake each spell the keys differently, but every one of them can express this.

entities:
  - name: order
    table: marts.fct_orders
    primary_key: order_id
    dimensions:
      - { name: country,    type: categorical }
      - { name: ordered_at, type: time, timezone: UTC }

metrics:
  - name: net_revenue
    label: Net revenue (EUR)
    description: >
      Paid orders, excluding test accounts, net of refunds.
      Months are calendar months in UTC.
    entity: order
    measure: { agg: sum, expr: amount_eur - refunded_eur }
    filter: status = 'paid' AND is_test = 0
    time_dimension: ordered_at
    allowed_dimensions: [country]

The description is not decoration. It is the line a finance lead reads when they ask why the dashboard does not match the invoicing system, and it is the text an AI assistant reads to decide whether “net revenue” answers the user’s question.

How does a semantic layer turn a question into SQL?

A request to a semantic layer names a metric, not a table: net_revenue, grouped by country, at month grain. The compiler looks up the measure, applies the metric’s filter, adds the time bucket and the group-by, and emits SQL in the warehouse’s dialect:

SELECT
    toStartOfMonth(ordered_at, 'UTC') AS month,
    country,
    sum(amount_eur - refunded_eur) AS net_revenue
FROM orders
WHERE status = 'paid'
  AND is_test = 0
GROUP BY month, country
ORDER BY month, country;
month        country  net_revenue
2026-09-01   DE       170
2026-09-01   FR       150
2026-10-01   FR        60

September is now 320 (170 + 150) on every surface that asks, because no surface writes its own filter. If finance later decides that months should follow Berlin time, someone changes one line, the change goes through review, and every chart, alert and export moves together.

Real compilers do more than this toy. They choose join paths from the relationship graph, refuse dimension combinations that would fan out (summing order amounts after joining to order lines double-counts them), and apply access rules before the SQL leaves the layer. Cube, for example, says its “access control runs at the semantic layer, so the same policies apply to every consumer” in its introduction. For a full build on one warehouse, see how to build a semantic layer in ClickHouse.

What breaks without a semantic layer?

The worked example shows the first failure. The others follow from it.

The same metric drifts across tools. Each dashboard, notebook and spreadsheet keeps its own copy of the logic. Copies are edited independently, so they diverge, and nobody notices until two numbers meet in the same meeting.

Changing a definition is a search-and-replace project. When finance decides refunds should be netted, someone has to find every query that computes revenue. Saved queries in a BI tool are rarely searchable as code, so some are missed.

Joins are reinvented, and sometimes wrong. Each author decides how orders join to customers and to order lines. A fan-out join that silently inflates a sum still produces a plausible chart, and it can survive for months.

Access rules are duplicated. If row-level security lives in each dashboard instead of in a shared layer, every new dashboard is a chance to forget it.

AI assistants guess. A language model pointed at raw tables has to infer which column means revenue and which rows to exclude. It will often produce valid SQL with the wrong business logic, the same failure as the dashboard above but faster and more confident. dbt’s documentation makes the same point about its MCP server: AI tools connected to the semantic layer give answers that “use your governed metrics instead of guessing at raw tables”. This is the main reason semantic layers came back into fashion, and why vendors including dbt Labs, Snowflake, Databricks and Salesforce are working on the Open Semantic Interchange, a shared format for these definitions whose first specification is published under Apache 2.0, according to dbt Labs.

Where can a semantic layer live?

There are four common homes, and the choice decides which tools can reuse your definitions.

Where it livesExamplesReusable by other tools?Trade-off
Inside the BI toolLookML in Looker, Power BI semantic modelsMostly within that vendor’s toolsStrongest integration with the tool’s dashboards; definitions are tied to it
Next to transformation codedbt Semantic Layer (MetricFlow engine)Yes, through APIs and integrationsLives in the same repo as models; hosted querying requires a paid dbt plan
Standalone serviceCubeYes, through SQL, REST and GraphQL APIsAnother service to run, with its own caching layer
Inside the warehouseSnowflake semantic views, Databricks metric viewsYes, for tools that read those objectsTied to that warehouse

Licensing differs too. MetricFlow, the engine behind the dbt Semantic Layer, is distributed under Apache 2.0 from version 0.209.0, according to its GitHub README; defining and querying metrics through the hosted dbt Semantic Layer requires a dbt Starter or Enterprise-tier account. For a longer look at how vendors use the terms semantic layer, metric layer and headless BI, see semantic vs metric vs headless BI.

When do you not need a semantic layer?

A semantic layer is a discipline as much as a tool, and it costs real time to maintain. Several situations do not justify it yet.

  • One consumer, few metrics. If all reporting happens in one BI tool and you have a dozen metrics that one analyst owns, that tool’s own modeling features (calculated fields, saved metrics) already give you a single definition. Adding a separate layer adds a second place to look.
  • Exploratory work. Data science and one-off investigations need raw tables and freedom. Forcing every question through predefined metrics slows them down without improving accuracy.
  • The upstream models are unstable. If tables are renamed weekly and nobody agrees on grain, defining metrics on top fixes nothing. Stabilize the transformation layer first; data quality tests are a better first investment.
  • Nobody owns the definitions. A semantic layer encodes decisions. If no one has authority to say what “active customer” means, the YAML will just record the argument.

The signal that you do need one is usually social, not technical: the same metric shows two values in two places and people stop trusting both; a second BI tool or an embedded analytics feature arrives; or someone wants an AI assistant to answer questions about the business. At that point, the cost of writing definitions down is lower than the cost of reconciling numbers by hand.

How to start small

You do not need to model the whole warehouse. A first pass that pays off quickly:

  1. List the ten metrics leadership looks at weekly. Revenue, active customers, churn and conversion are typical.
  2. For each one, find every place it is computed today and note the differences in filters, joins and time zones.
  3. Get one owner to decide each difference and write the decision into the metric’s description.
  4. Define those ten metrics in the semantic layer, with only the dimensions people actually use.
  5. Repoint the most-viewed dashboards to the defined metrics and retire the old queries.

Ten well-owned metrics consumed everywhere beat two hundred defined metrics that half the dashboards ignore.

Several tools can host that first pass. If your warehouse is ClickHouse, Goni is one option: full disclosure, this is our product. Metrics are defined in a git-tracked YAML semantic layer that compiles to ClickHouse SQL, and the same definition backs charts, dashboard tiles, alerts and AI Q&A, which can only plan against metrics and dimensions that exist in the catalog. The compiled SQL is visible for any metric. The drawbacks are real: ClickHouse is the only warehouse Goni queries, it is not open source, and it is younger than Looker, dbt or Cube. There is a 14-day free trial if you want to define your first ten metrics there.

FAQ

What is a semantic layer in simple terms?

It is a shared dictionary for your data, written as code. It defines what each business metric means (which rows, which filters, which time zone) and how tables join, then generates the SQL for any tool that asks. Every dashboard, spreadsheet and AI assistant gets the same number for the same question.

What is an example of a semantic layer?

LookML in Looker, Power BI semantic models, the dbt Semantic Layer powered by MetricFlow, Cube, Snowflake semantic views and Databricks metric views are all semantic layers. They differ in where the definitions live and which tools can reuse them, but all define metrics, dimensions and joins once and compile queries from those definitions.

Is a semantic layer the same as a data warehouse?

No. The warehouse stores and computes the data. A semantic layer stores no rows of its own in most implementations; it holds definitions and turns requests into SQL that the warehouse runs. Some semantic layers add a cache or pre-aggregated tables for speed, but the warehouse remains the source of the data.

Is dbt a semantic layer?

dbt’s core job is transformation: building tables and views from SQL models. The dbt Semantic Layer is a separate capability on top of those models, powered by the MetricFlow engine, where you define metrics and query them through APIs. Hosted querying requires a dbt Starter or Enterprise-tier account; MetricFlow itself is Apache 2.0 licensed.

Do I need a semantic layer for AI analytics?

For questions about defined business metrics, it is the most reliable grounding available. Without one, a language model infers filters and joins from column names and often returns valid SQL with the wrong business logic. With one, the model picks a metric and dimensions, and the semantic layer writes the SQL from agreed definitions.