feat(sdk): support downstreams for metrics
Closed
AN
3d ago+557+557+012345678901234567890123456789-10-10-01234567890123456789
Summary
- Add an opt-in
set_upstream_metricsAPI on chart, dashboard, and dataset so they can write the consumer-ownedupstreamMetricsaspect. Omitting it leaves existing edges alone;[]clears them. Metric URNs are rejected from dataset lineage setters. - Snowflake semantic views still emit no metric downstream edges. Semantic-view metadata names where a metric is defined, and that logical dataset is already the metric's upstream, so the reverse edge would be a dataset-metric cycle.
Related to CAT-3323.
Test plan
-
metadata-ingestion/tests/unit/sdk_v2/test_upstream_metrics.pycovers omit, replace, clear, dedupe, and metric-URN rejection on chart and dataset upstreams - Existing chart, dashboard, and dataset SDK goldens stay unchanged
-
test_no_upstream_metrics_emitted_for_semantic_viewasserts a table-bound metric still points at its logical dataset and no workunit carriesupstreamMetrics - Confirm a chart upsert that omits
upstream_metricsdoes not clear edges previously written byupdateLineage
Made with Cursor
Summary by cubic
Adds an opt-in set_upstream_metrics API on chart, dashboard, and dataset entities so consumers can declare the metrics they read, stored on the upstreamMetrics aspect. Metric URNs are now rejected from dataset lineage setters to prevent accidental dataset–metric edges.
- Omitting the argument leaves existing edges unchanged;
[]emits an empty list that clears them on upsert. - Accepts metric URNs,
Metricentities, or strings; validates input and dedupes before writing. - Dataset lineage setters (
set_upstreams,set_input_datasets,add_input_dataset) on datasets, charts, and dashboards now raise when given a metric URN. - Snowflake semantic views still emit no metric downstream edges: their metadata names where a metric is defined, and a reverse edge would create a dataset–metric cycle.