Skip to main content

11. Business Semantics

You'll stop arguing about whose revenue number is right by defining KPIs once as Unity Catalog metric views — usable from SQL, dashboards, and Genie. Budget about 1 hour: 20 min reading, 30–45 min hands-on.

Prereqs: Unity Catalog foundations, Data governance strategy, Databricks AI/BI

Journey checklist

  • Get started.
  • Before you start.
  • Infra setup.
  • Cost monitoring.
  • Data governance strategy.
  • Access your data.
  • Build the first pipeline.
  • Automation and orchestration.
  • Query and explore.
  • Databricks AI/BI.
  • Business Semantics
    • Understand the metric drift problem
    • Read and write a metric view in YAML
    • Hands-on lab — same KPI returns the same number in SQL, AI/BI, and Genie

UC Metric Views reference

warning

Review this deck before proceeding. It covers the full metric views surface — motivation, architecture, dimensions, measures, and querying patterns.

Open PDF

The problem: same KPI, different numbers

Three teams report Q1 revenue. Three different numbers.

  • Sales: SUM(amount) WHERE status = 'closed' → $4.2M
  • Finance: SUM(amount) WHERE invoice_date >= '2026-01-01' → $4.0M
  • BI dashboard: SUM(net_amount) joined to a refunds table → $3.8M

Each is reasonable. Each lives in a different SQL file or BI tool. Nobody owns the canonical definition. Leadership picks the one they trust most this week.

The fix: define metrics once, in the catalog

A metric view is a Unity Catalog object that holds the formula, the grain, and the filters for a KPI. SQL editors, notebooks, AI/BI dashboards, and Genie all call the same object — they cannot drift.

SELECT `Order Month`, MEASURE(`Total Revenue`)
FROM main.sales.orders_metrics
WHERE `Order Month` >= '2026-01-01';

Same query in any tool. Same number, every time.

Where it sits

  • Unity Catalog:

    • A metric view is a first-class Unity Catalog object — discoverable, permissioned, and audited like a table. The body is YAML wrapped in a CREATE VIEW … WITH METRICS LANGUAGE YAML statement.
    • Contained inside a schema. Same level as tables, views, functions and models: UC three-level namespace.
  • BI Analytics and Reports: Source of truth for first-party AI/BI or third-party apps.

    • Dashboard or Genie Space or Third-party app → Metric View(s) → UC tables.

Watch first

Metric View main parts

PartWhat it doesExample
SourceThe Unity Catalog table or SQL query the metric reads fromsamples.tpch.orders
MeasuresAggregate expressions — the numbersSUM(o_totalprice)
DimensionsSlice/group columnsDATE_TRUNC('MONTH', o_orderdate)
FilterOptional row scoping before aggregationo_orderdate > '1990-01-01'

In conclusion, are Metric Views basically an OLAP cube?

Not exactly. They share the conceptual DNA: measures + dimensions + filters but differ fundamentally in implementation:

  • OLAP cubes pre-aggregate and materialize data into a multidimensional structure. You pay storage and build time upfront for fast slice-and-dice at query time.
  • Metric views are a semantic layer, not a physical structure. They define reusable metric logic (aggregations, dimensions, time grains) as SQL-based definitions in Unity Catalog. At query time, the engine generates and executes SQL against the underlying tables — no pre-aggregation, no materialization (unless it's configured).

Go deeper

Next