# What is a semantic layer?

One shared definition of business terms and metrics, such as revenue or active customer, that reports, dashboards and AI assistants all read instead of writing their own.

- Page: https://tecyfy.com/concepts/semantic-layer
- Subject: Data engineering in the AI era (https://tecyfy.com/concepts)
- Level: intermediate
- Also called: Metrics layer

Ask 3 teams for last quarter's revenue and you can get 3 numbers. Finance counts it when the invoice is paid. Sales counts it when the contract is signed. The product team leaves out refunds. Each is right by its own definition, and each definition lives in a different dashboard's SQL.

A semantic layer writes the definition down once. Revenue, active customer, churn rate: each metric is defined in one place, with its formula, its filters and the ways it can be broken down. Every report, notebook and AI assistant reads that definition instead of writing its own.

## What it holds

A semantic layer sits between the tables and the tools that query them. For each metric it records:

- the **measure**: how the number is calculated, such as the sum of paid order totals minus refunds,
- the **dimensions** it can be grouped by: region, month, product line,
- the **source** tables and joins it is built on,
- and plain **names and descriptions**, including the other words people use for the same thing.

The point is that a definition changes in one place. With dbt's semantic layer, change how revenue is calculated and the change reaches every tool that asks for revenue.

## 2 examples

dbt's semantic layer, built on its MetricFlow engine, moves metric definitions out of individual BI tools and into the dbt project, alongside the models they are built on.

Databricks has **metric views** in Unity Catalog. A metric view is a YAML definition with a source table, filters, fields to group by and measures. A query reads a measure with the `MEASURE()` function, so the formula is never retyped. Version 1.1 of the format adds synonyms, up to 10 per field or measure, so "turnover" and "sales" can point at the same revenue.

## Why AI made it necessary

Before assistants, a missing definition cost a meeting. Analysts argued about the number and agreed one. An assistant does not argue. Asked "what was revenue last quarter?", a model writing SQL against raw tables has to decide on its own whether refunds count, and it will not tell you it decided.

A semantic layer takes that decision away from the model. On Databricks, Genie, the assistant that turns questions into SQL, can query metric views, and their synonyms help it match a question's words to the right measure. AI tools such as Claude and ChatGPT can connect to dbt's semantic layer through an MCP server, so their answers use the agreed metrics instead of guessing at raw tables.

That is the difference between [text-to-SQL](https://tecyfy.com/concepts/text-to-sql) that guesses and text-to-SQL that looks up. The model still has to understand the question. It no longer has to invent what the business means by its own words.

## Related

- [Text-to-SQL](https://tecyfy.com/concepts/text-to-sql): A model turning a question in plain words into a database query, so people can ask the data directly. It is only as right as its knowledge of the tables and their meaning.
- [Data Warehouse](https://tecyfy.com/concepts/data-warehouse): A database built for analysis: cleaned, structured data from many systems, kept in one place and shaped for fast reports and dashboards.
- [Data Lineage](https://tecyfy.com/concepts/data-lineage): The record of where a piece of data came from and everything it passed through, from source tables to the dashboards, models and AI answers built on it.

## Sources

- [dbt Semantic Layer](https://docs.getdbt.com/docs/use-dbt-semantic-layer/dbt-sl)
- [Unity Catalog metric views](https://docs.databricks.com/aws/en/metric-views/)
- [Metric view YAML syntax reference](https://docs.databricks.com/aws/en/uc-semantics/metric-views/yaml-reference)
- [Genie Agents concepts](https://docs.databricks.com/aws/en/genie-agents/concepts)
