feat(sdk): set metric column-level upstreams

Merged
AC
3d ago
+103-4

MetricUpstreams.fieldUpstreams is in the model, validated by MetricUpstreamsValidator, and drawn by the lineage graph as column → metric edges. The SDK Metric had no way to set it.

  • Metric(upstream_fields=...), set_upstream_fields(...) and the upstream_fields property. They accept str or SchemaFieldUrn, singly or as a list.
  • A field whose dataset is not in upstream_datasets raises ValueError. So does narrowing upstream_datasets under existing fields. GMS rejects both, so the error now comes from the SDK call instead of the write.
  • Passing an empty list writes fieldUpstreams: [], which clears stale column edges on re-ingest. Leaving upstream_fields unset leaves the aspect as it was.

It is split out from the MicroStrategy stack, where the semantic-model metrics use it.

šŸ¤– Generated with Claude Code


Summary by cubic

Adds upstream_fields support to the SDK Metric, so column-level upstreams can be set on metrics. The model already stores and validates MetricUpstreams.fieldUpstreams and the lineage graph draws it as column → metric edges, but the SDK had no way to populate it.

  • Metric(upstream_fields=...) accepts a single str or SchemaFieldUrn, or a list of them; set_upstream_fields(...) and the upstream_fields property accept the same.
  • A field whose dataset is not in upstream_datasets raises ValueError, as does narrowing upstream_datasets under existing fields; GMS rejects both, so the error now surfaces at the SDK call instead of the write.
  • Passing an empty list writes fieldUpstreams: [], clearing stale column edges on re-ingest; leaving upstream_fields unset leaves the aspect unchanged.