feat(ingest/dbt,cube): column-level lineage for metrics
What
dbt and Cube build metrics through the SDK Metric builder but only wrote dataset-level upstreams. They now also write metric column lineage (metricUpstreams.fieldUpstreams) to the logical-dataset columns each metric aggregates. The logical-to-physical column mapping is unchanged and stays on the logical dataset's upstreamLineage.
dbt
- A
create_metric: truemeasure's metric reads its own measure column. - A top-level
metrics:entry reads the column of each measure it resolves, using the same per-model resolution as the dataset upstreams (_locate_measure). A ratio built over measures reads a column on each side, across semantic models where it spans them. - A metric built on other metrics (derived, or a ratio whose sides name metrics) also reads the measure columns dbt lists in its
input_measures, which a compiled manifest fills with the measures of every metric it builds on. ItsderivedFromedges to those metrics are unchanged.
Cube
- Each view-measure metric reads that member's column on its logical dataset, matching the
agg(alias.member)expression.
Config-gated. Metric column lineage follows the connector's column-lineage option: dbt include_column_lineage, Cube include_lineage and include_column_lineage. When it is off, fieldUpstreams is left unset (upstream_fields=None) rather than written as [], the same way dataset upstreamLineage leaves fineGrainedLineages unset when the option is off. Because metricUpstreams is upserted as a whole aspect, both choices leave the server in the same state: column edges written by an earlier run are cleared. Dataset-level metric upstreams are not affected by the option. The Cube semantic-model warning no longer says include_column_lineage is ignored.
No dangling edges. Field paths come from the same field set that builds the logical schema (dbt: the annotated measures, with convert_column_urns_to_lowercase applied; Cube: the logical dataset's schema, built from the same members). A measure dbt declares that cannot be resolved is left out and counted in num_metric_upstream_fields_unresolved rather than warned about per metric; a ratio side that names another metric is a derivedFrom edge and is not counted. Every field edge in the regenerated goldens was checked against the emitted schemaMetadata.
Goldens
Only metricUpstreams.fieldUpstreams changed (empty list ā schemaField edges); datasetUpstreams is unchanged. The multi-project glob and Cube goldens contain only those aspect changes, with no unrelated audit-stamp or lastObserved noise.
Docs
- dbt and Cube connector docs describe the metric column lineage and the option that controls it.
Checklist
- The PR conforms to DataHub's Contributing Guideline (particularly PR Title Format)
- Links to related issues (if applicable)
- Tests for the changes have been added/updated (if applicable)
- Docs related to the changes have been added/updated (if applicable). If a new feature has been added a Usage Guide has been added for the same.
- For any breaking change/potential downtime/deprecation/big changes an entry has been made in Breaking Changes (not a breaking change)
š¤ Generated with Claude Code
Summary by cubic
dbt and Cube metrics now carry column-level lineage to the logical-dataset columns they aggregate, on top of the existing dataset-level upstreams.
Behavior
- Each metric's
fieldUpstreamsis written only when column lineage is enabled (dbt:include_column_lineage; Cube:include_lineageandinclude_column_lineage). With it off,fieldUpstreamsstays unset yet still clears column edges an earlier run wrote. - A dbt
create_metricmeasure reads its own column; a top-level metric reads the columns of each measure it resolves, both sides of a ratio included, plus the input measures dbt expands a derived metric into. Fields follow the dbt column lowercase rule. - A Cube view-measure metric reads that member's column on its logical dataset; the field always exists since the logical schema is built from the same members.
- A dbt declared measure that resolves to no column is left out and counted once in
num_metric_upstream_fields_unresolved, so no edge points at a column the dataset does not carry. - dbt and Cube connector docs now describe metric column lineage, and the Cube semantic-model warning no longer claims
include_column_lineageis ignored.