Repository navigation
feat(ingest/unity,microstrategy): metric column lineage - #21776
sgomezvillamor wants to merge 16 commits into
Conversation
…property helpers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…semantic models Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Unity Catalog metric view measures and MicroStrategy metrics now write metricUpstreams.fieldUpstreams to the logical-dataset fields they read. - Unity: a measure's column refs (the same parse that picks its dataset upstreams) resolve to the dimension or join key field exposing that column. Columns with no such field are counted in num_metric_view_measure_columns_without_field. - MicroStrategy: each fact or attribute a metric reads (including through a consolidation) points at its field on every logical table exposing it. Ones no table exposes are counted in semantic_model_metric_upstream_fields_unresolved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A measure's column lineage pointed at any field named after the column, even a dimension that transforms another column. Measure columns now map only to a dimension whose expression is that column, parsed with sqlglot so quoted and qualified spellings match. Join keys keep the name fallback so they do not overwrite a dimension of the same name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The lineage query's Metric fragment fails GraphQL validation on servers older than v1.7.0. Send it through schema projection so the fragment is dropped there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reuse the existing edge for a metric that stays, as the other edge setters do, so a hydrated entity keeps its stamps and properties. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A dataset URN passed to derived_from now raises InvalidUpstreamUrnError with a hint to use upstream_datasets, and remove_derived_from matches canonical URNs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Connector Tests ResultsConnector tests failed for commit To skip connector tests, add the Autogenerated by the connector-tests CI pipeline. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…at-unity-mstr-metric-column-lineage # Conflicts: # docs/api/tutorials/semantic-models.md
…ric-column-lineage Master now has the SDK changes (squash-merged), the Unity metric view follow-ups, and MicroStrategy metric column lineage. Unity measure column lineage is rebuilt on the new expression parser; MicroStrategy keeps master's implementation and adds the unresolved-field counter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR SummaryOverview Measure expressions reuse the existing sqlglot parse: logical table/column refs feed MicroStrategy semantic-model metrics already emitted field upstreams; this PR adds Docs, integration golden MCes, and unit tests cover resolved vs unresolved columns, Reviewed by Cursor Bugbot for commit 7f39f16. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f7750a7. Configure here.
There was a problem hiding this comment.
All reported issues were addressed across 9 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
…neage With include_column_lineage off, metric view measures no longer write fieldUpstreams or count columns without a field, matching how the logical datasets leave out their fine-grained lineage. The unresolved-column counter now goes through the deferred report updates, so a view that fails to serialize leaves it unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Builds on #21764, which added
upstream_fieldsto the SDKMetricbuilder, and on #21745 (Unity metric view follow-ups). Sibling PRs do the same for dbt and Cube (#21768) and Snowflake (#21770).What changes
Databricks Unity Catalog metric views build metrics through the SDK but only wrote dataset-level upstreams. They now also write metric column lineage (
metricUpstreams.fieldUpstreams) to the logical-dataset fields each measure reads. MicroStrategy already writes metric column lineage (#21737); this PR only adds a counter for what it can't resolve. The logical-to-physical column mapping is unchanged in both.Unity Catalog (metric views, semantic model mode)
expralready goes through one sqlglot pass (_parse_expression) to find the logical tables it reads. That pass now also records the logical column each reference reads, so the dataset and column upstreams come from the same parse. There is no second parser.expris just that column (quoted, qualified or not), or a join key field. Join keys use the same column-to-field index, which replaces the text match on dimension expressions. A struct field (source.address.city) is not the column itself, so it doesn't count.num_metric_view_measure_columns_without_field. There is no warning: the measure's dataset edge still covers the column, and nothing in the YAML is wrong.order_date,source.order_date,ORDER_DATE) fold to one edge.include_column_lineage, like the logical datasets' column lineage. When it is off, metrics keep their dataset upstreams,fieldUpstreamsis left unset and nothing is counted.MicroStrategy (semantic model)
datasetUpstreamsandfieldUpstreams. It is now counted insemantic_model_metric_upstream_fields_unresolved.Design decisions
SUM(o_totalprice)over a column that no dimension exposes gets no column edge. Join keys are already added as fields so that relationships have something to point at. Measure input columns could be added the same way, which would give most measures a column edge, but it would change every logical dataset's schema. This PR leaves that out (see the question below).include_column_lineage: falseleavesfieldUpstreamsunset rather than writing[]. The logical datasets do the same withfineGrainedLineages. Leaving it unset does not keep earlier column edges in DataHub: the metric still writes its dataset upstreams, andmetricUpstreamsis written whole, so DataHub ends up with no column edges either way.extract_lineage/extract_model_lineagegate the logical-to-warehouse lineage, which this PR does not touch.Tests
tests/unit/unity/test_unity_metric_view_semantic_model.py): one test covers the resolved cases (a source dimension, a dimension on a joined table, a join key), three spellings of the same column folding to one edge, the unresolved case (counted, dataset edge kept), and no new warnings. Another test checks that withinclude_column_lineage: falsemetrics keep their dataset edges, have nofieldUpstreamsand count nothing. The failed-view test also checks the unresolved-column counter stays at zero.tests/unit/microstrategy/test_microstrategy_semantic_model.py): a fact on two tables gives a field edge on each, a repeated fact token adds nothing, an attribute gives a field edge, and a fact on no table is counted. The consolidation test also checks the attribute's field edge."fieldUpstreams": []on its four metrics. Its measures reado_totalpriceando_orderkey, which no dimension exposes, so they get no column edge, as expected.pytest tests/unit/unity tests/integration/unity tests/unit/microstrategy tests/integration/microstrategy tests/unit/sdk: 1650 passed, 1 xfailed.Questions for the reviewer
Checklist
🤖 Generated with Claude Code