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.
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-SQLText-to-SQLA 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. 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.
Sources