feat(ingest/unity): ingest metric views as semantic models and metrics
Summary
Databricks Unity Catalog metric views can now be ingested as first-class semanticModel and metric entities, using the same mapping and switch as Snowflake semantic views.
Each metric view becomes:
| Metric view YAML | DataHub |
|---|---|
| the metric view | semanticModel, with the YAML as its native definition |
source and each joins[].name, nested joins included | one logical dataset (subtype Semantic Model Dataset), with upstream and column-level lineage to the physical table |
joins[].on / using | relationships between the logical datasets |
dimensions | annotated fields on the logical dataset their expr reads |
measures | one metric each, upstream of the logical datasets its expr reads |
MEASURE(name) inside a measure | derivedFrom edge to that metric |
Switch
emit_semantic_model_entities is tri-state and resolved with the shared semantic_model_gate, as for Snowflake. Left unset, it turns on against DataHub Cloud 2.1.0 or later with Metrics enabled, and stays off on OSS and on runs with no server connection. true requests it and false keeps Metric View datasets. It only applies with include_metric_views: true.
Behaviour when on
- Replaces the dataset, as Snowflake does: the
Metric Viewdataset is not emitted, and stateful ingestion removes previously ingested ones. - Usage and profiling skip metric views, since they would otherwise recreate that dataset.
- Genie agents that use a metric view get lineage to its logical datasets, because their lineage aspect only takes dataset upstreams.
- Fallback: a metric view whose YAML can't be read is still emitted as a dataset, and the report says so.
Not inventing what the YAML doesn't say
- A dimension whose
exprreads one table goes on that table's logical dataset; unqualified columns readsource. One that reads several tables goes onsource, the grain the metric view is computed at, and is counted in the report. Column-level lineage still points at every column it reads. - A join becomes a relationship only when its
oncompares columns qualified with both tables' names, or it has ausinglist. Join keys not covered by a dimension are added as fields. Joins with unqualifiedoncolumns are skipped and reported rather than guessed. Cardinality is left unset because the YAML doesn't state it. - The view
filterand a measure'swindowchange what a measure computes but are not part ofexpr, so they are kept as trailing comments on the metric expression, as the dbt source does for filters and cumulative windows.
Not included
- No migration of edits made on existing
Metric Viewdatasets (owners, docs, terms). Snowflake hasdatahub migrate snowflake-semantic-viewsfor this; a Unity version would be a follow-up.
Test plan
- New integration golden (
test_metric_view_ingestion_semantic_model) on the existing metric view mock data. Existing metric view goldens are unchanged. - Unit tests for:
- the dataset being replaced, and metric views staying out of
table_refs; - dimension placement, including the multi-table case;
- relationships from qualified
onand fromusing, plus skipping unqualifiedon; - metric upstreams and
derivedFrom, and the filter comment; - fallback on unreadable YAML;
- switch resolution;
- Genie redirect.
- the dataset being replaced, and metric views staying out of
- 560 Unity unit and integration tests pass. mypy is clean; ruff and markdown formatting run via Gradle.
Checklist
- PR title follows the Contributing Guideline
- Tests added
- Docs updated (Unity connector docs, Metrics & Semantic Models guides)
- Breaking change entry added to
docs/how/breaking-changes.md(auto-enables on DataHub Cloud forinclude_metric_viewsusers)
š¤ Generated with Claude Code
Summary by cubic
Databricks Unity Catalog metric views can now be ingested as semanticModel and metric entities instead of Metric View datasets, using the same mapping and switch as Snowflake semantic views.
Switch and behavior
emit_semantic_model_entitiesis tri-state; unset, it auto-enables on DataHub Cloud 2.1.0+ with Metrics enabled and stays off on OSS and connectionless runs, and only applies withinclude_metric_views: true.- When on, the
Metric Viewdataset is not emitted, stateful ingestion removes previously ingested ones, and usage and profiling skip metric views so profiles no longer recreate the replaced dataset URN. - Genie agents and notebooks that use a metric view get lineage to its logical datasets, and a metric view whose YAML can't be read is still emitted as a dataset.
- Table lineage pointing at a metric view now points at its logical datasets; a logical dataset whose YAML source is a subquery takes its upstreams from Catalog table lineage when it's the only unresolved table, and is reported otherwise.
- Skipped YAML join entries are reported, and
emit_semantic_model_entitieswarns when metric views are not ingested. - Edits made on existing
Metric Viewdatasets (owners, docs, terms) are not migrated; a Unity version of the Snowflake migration command would be a follow-up.
Mapping
- Each metric view becomes a
semanticModelwith the YAML as native definition, one logical dataset persource/joinsentry with lineage, and onemetricper measure, withderivedFromedges forMEASURE()references. - Relationships are created only when a join's
onqualifies columns on both tables or it has ausinglist; unqualified joins are skipped and reported. - Dimensions are annotated fields on the logical dataset their
exprreads; dimensions reading multiple tables go onsource. - View filters and measure windows become trailing comments on metric expressions.
- Logical dataset browse paths drop the self-entry that previously added the dataset's own name to the path.