Skip to main content

What is a semantic layer?

Summary

  • A semantic layer is a business representation of corporate data. It lets people access data with common business terms such as product, customer or revenue instead of table and column names.
  • Its core job is one governed definition per metric. Define "total revenue" once and query it by any dimension, so dashboards, SQL and AI tools return the same answer.
  • In Databricks, metric views are the core implementation of Unity Catalog semantics. They separate measure definitions from the dimensions used to group and filter them, and AI/BI dashboards, Genie Agents and alerts can query them.
  • Genie Ontology (Public Preview) builds on that layer. It combines the semantics you define with context Genie infers from your assets and usage.

What is a semantic layer?

A semantic layer is a business representation of corporate data that helps people access data using common business terms. It maps complex data into familiar terms such as product, customer or revenue, so users do not need to know the relational structure underneath. In Databricks, Unity Catalog semantics is "a collection of tools to help you define standard business metrics, terms, and organizational structures on top of your catalog data".

Why do semantic layers matter?

Standard views lock in aggregations and groupings at creation time. With a metric view, you define the metric once and users can group by any available field. If each team writes its own SQL for a metric instead, definitions can drift and reports can disagree. A shared definition also gives AI tools something precise to use: Databricks' guidance says defining measures and dimensions once in a metric view "is one of the most important steps for accuracy because it removes the ambiguity that causes agents to choose the wrong definition".

What are the core components of a semantic layer?

Component What it does In Databricks
Measures Aggregations expressed in business terms and defined once Metric view measures, queried with MEASURE()
Dimensions Categories used to group and filter Metric view fields (dimensions is an accepted synonym)
Relationships How entities join Joins from a source table to dimension tables, including multi-hop joins across normalized tables
Business terms Authoritative definitions of terms and acronyms Pages (Beta), organized in domains
Trust signals Mark assets as trusted or outdated Certification and deprecation
Governance Control who can use what Metric views are Unity Catalog securable objects governed with standard privileges
AI context Help AI tools find the right field Agent metadata: display names, format specifications and synonyms

How does a metric view work in Databricks?

A metric view is defined in YAML that declares a source, fields and measures. In SQL, you wrap the YAML in a CREATE VIEW statement with a WITH METRICS clause.

CREATE OR REPLACE VIEW orders_metric_view WITH METRICS LANGUAGE YAML AS
$$
  version: 1.1
  source: samples.tpch.orders
  fields:
    - name: Order Month
      expr: DATE_TRUNC('MONTH', o_orderdate)
  measures:
    - name: Total Revenue
      expr: SUM(o_totalprice)
$$

Every measure in a query must be wrapped in the MEASURE() aggregate function, and you list columns explicitly rather than using SELECT *:

SELECT
  `Order Month`,
  MEASURE(`Total Revenue`)
FROM orders_metric_view
GROUP BY ALL
ORDER BY `Order Month`;

How do semantic layers help AI agents?

A Genie Agent is based on data registered to Unity Catalog, including views and metric views, and Genie uses "the metadata attached to Unity Catalog objects, as well as an author-curated agent-level knowledge store, to generate responses". Agent metadata in metric views adds display names, format specifications and synonyms, and synonyms are imported automatically to help Genie discover fields and measures.
Genie Ontology goes further and is in Public Preview. The semantics above are "the human-modeled layer of the Genie Ontology", and Genie One combines that modeled context with context it infers from your assets and usage. When a question involves a term defined in a Page, Genie One prioritizes the Page's definition and cites it.

How do I build a semantic layer on Databricks?

The Databricks guidance is incremental: you do not have to cover the whole business before going live, so choose one high-value domain first.

  1. Define measures and dimensions once in a metric view over governed tables.
  2. Declare relationships. Primary and foreign keys in Unity Catalog tell agents how tables relate, so "they join correctly instead of inventing paths". These constraints are informational rather than enforced, so your governance process has to keep them accurate.
  3. Define business terms in Pages and group assets in domains.
  4. Add agent metadata, such as display names and synonyms.
  5. Certify the assets your organization vouches for, which steers Genie One toward them.

FAQs

Do I need a semantic layer?

A shared layer helps most when several teams or tools compute the same metrics, or when AI tools generate SQL on your data. A single analyst running one-off queries may not need one.

Is a semantic layer the same as a data catalog?

No. A catalog records which data assets exist, while a semantic layer defines what the data means in business terms. Unity Catalog semantics is built on top of your catalog data.

Is a semantic layer the same as an ontology?

Not quite. In the words of the Databricks blog on operationalizing Genie Ontology, semantic models "capture the business concepts you deliberately define", and an ontology "extends that foundation with the broader relationships, knowledge, and context AI needs".

Which tools can query a metric view?

SQL editors, notebooks, AI/BI dashboards, Genie Agents, alerts, and JDBC and ODBC connections.

The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.