On Databricks, the native way to build a semantic layer is with Unity Catalog metric views: governed objects that define dimensions and measures over your tables, queried with SQL and used by Genie and AI/BI dashboards. You can also use the dbt Semantic Layer or a universal semantic layer on top of Databricks SQL. This guide shows how metric views work and when each option fits.
Unity Catalog metric views
A metric view is defined in YAML and created with SQL. It names a source table, optional joins, dimensions and measures:
CREATE OR REPLACE VIEW main.sales.order_metricsWITH METRICSLANGUAGE YAMLAS $$version: 1.1source: main.sales.fct_ordersdimensions: - name: order_month expr: DATE_TRUNC('MONTH', order_date) - name: region expr: regionmeasures: - name: net_revenue expr: SUM(net_amount) - name: order_count expr: COUNT(1) - name: average_order_value expr: SUM(net_amount) / COUNT(1)$$;You query it with the MEASURE() function, and Databricks computes each measure correctly at whatever grain you group by:
SELECT order_month, region, MEASURE(net_revenue), MEASURE(average_order_value)FROM main.sales.order_metricsGROUP BY ALL;Because the ratio is defined once, nobody averages pre-computed averages by mistake. Check the Databricks documentation for the current YAML specification, as it is still evolving.
Why metric views matter for Genie
Genie, Databricks' natural-language interface, answers questions by writing SQL. Given only tables, it has to infer joins and formulas. Given metric views, it can select approved measures and dimensions by name, so answers match your dashboards. Adding clear descriptions and synonyms to measures and dimensions improves it further.
Other ways to build a semantic layer on Databricks
| Option | When it fits |
|---|---|
| Unity Catalog metric views | Most data is on Databricks, and Genie, AI/BI and Databricks SQL are the main consumers |
| dbt Semantic Layer | You build models with dbt on Databricks and want metrics versioned in the same project |
| Universal semantic layer (AtScale, Cube) | Several BI tools, Excel, or embedded analytics need one model |
| Power BI semantic model | Reporting is mostly in Power BI on Databricks data |
Many teams combine them: definitions kept in one neutral place and published to Databricks as metric views, so Genie benefits without the definitions being locked to one platform. See best semantic layer tools.
Getting the model right first
Metric views sum and count whatever the source table holds. If a fact table mixes grains or joins fan out, the metric view returns wrong numbers consistently. Before creating metric views, make sure each fact has a declared grain, dimensions are conformed, and relationships have the right cardinality.
Frequently asked questions
Does Databricks have a semantic layer?
Yes. Unity Catalog metric views provide governed dimensions and measures, used by Databricks SQL, AI/BI dashboards and Genie.
What is the difference between a metric view and a normal view?
A normal view returns fixed rows. A metric view defines measures that are computed at whatever grouping you query, with the MEASURE() function, so ratios and distinct counts stay correct.
Can I use the dbt Semantic Layer with Databricks?
Yes, the dbt Semantic Layer supports Databricks as a platform.
Publish metric views from your data model
offdataai derives metrics from a validated data model and publishes them to Databricks as Unity Catalog metric views, reading query history to suggest which joins and measures matter, so Genie answers from approved definitions. The same definitions also export to dbt, Snowflake semantic views and Apache Ossie. See the Databricks data model generator and our Unity Catalog comparison.
