feat(sdk,ingest): record column-level lineage on metrics

Closed
AN
3d ago
+816-39

Summary

  • Add Metric.set_upstreams(datasets=, fields=) so column parents are derived into datasetUpstreams and both upstream lists are always written. set_upstream_datasets remains as a deprecated alias that clears column edges.
  • Snowflake semantic views emit fieldUpstreams only for facts and dimensions whose logical dataset is already a dataset upstream. Physical column mapping stays on the logical dataset.

Test plan

  • pytest metadata-ingestion/tests/unit/sdk/test_metric.py
  • pytest metadata-ingestion/tests/unit/snowflake/test_snowflake_semantic_model.py
  • Confirm a Snowflake semantic-view ingest writes logical schemaField edges on metricUpstreams and leaves physical column lineage on the logical dataset

Made with Cursor


Summary by cubic

Records column-level lineage on metrics: the Python SDK gains Metric.set_upstreams(datasets=..., fields=...), and Snowflake semantic views emit column edges for facts and dimensions whose logical dataset is already a dataset upstream. metricUpstreams now always writes both datasetUpstreams and fieldUpstreams so re-ingestion clears stale table and column edges. Physical column mapping stays on the logical dataset.

Migration

  • Replace Metric.set_upstream_datasets(...) with set_upstreams(datasets=...); the old alias is deprecated and clears column edges.
  • Pass fields=self.upstream_fields when re-emitting a graph-hydrated metric — metricUpstreams is a snapshot, not a patch, so omitting fields drops server-side column lineage.