Skip to content
Open
Show file tree
Hide file tree
Changes from 72 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
968862a
refactor(sdk): share dataset URN parsing, browse-path and structured-…
sgomezvillamor Dec 1, 2026
c9cdcb9
feat(sdk): column-level lineage on metrics
sgomezvillamor Dec 1, 2026
a56cb31
feat(sdk): declare upstream metrics on charts, dashboards and datasets
sgomezvillamor Dec 1, 2026
676d966
feat(sdk): external URL, subtype, browse path and field metadata for …
sgomezvillamor Dec 1, 2026
a081564
feat(sdk): metric lineage in the lineage client
sgomezvillamor Dec 1, 2026
bcfe6c5
docs(sdk): examples and docs for metric lineage
sgomezvillamor Dec 1, 2026
a6d203c
docs: link breaking-change entry to its PR
sgomezvillamor Dec 1, 2026
d6cb3b6
feat(ingest/dbt): column-level lineage for metrics
sgomezvillamor Dec 1, 2026
9ac3bbc
feat(ingest/cube): column-level lineage for metrics
sgomezvillamor Dec 1, 2026
78fc668
docs(sdk): list dbt and Cube as writing metric column lineage
sgomezvillamor Dec 1, 2026
69f35af
fix(ingest/dbt): describe derived metric column lineage and count eac…
sgomezvillamor Dec 1, 2026
d56b42c
refactor(ingest/cube): drop unreachable metric field resolution check
sgomezvillamor Dec 1, 2026
7c5f6ae
fix(sdk): keep get_lineage working on servers without the Metric type
sgomezvillamor Dec 1, 2026
6d9198a
fix(sdk): keep edge metadata in set_upstream_metrics
sgomezvillamor Dec 1, 2026
c4a6af0
fix(sdk): validate derived_from inputs as metric URNs
sgomezvillamor Dec 1, 2026
b3700f3
docs(sdk): point to connector pages for metric column lineage support
sgomezvillamor Dec 1, 2026
2595c6f
Merge remote-tracking branch 'origin/feat-sdk-semanticmodels' into fe…
sgomezvillamor Dec 1, 2026
5c5cd3a
fix(sdk): address review feedback on metric lineage inputs
sgomezvillamor Dec 2, 2026
1e0a326
fix(sdk): make list set_* methods on Dashboard and DataJob replace
sgomezvillamor Dec 2, 2026
a10a0b4
fix(sdk): take a single string as a one-entry browse path
sgomezvillamor Dec 2, 2026
378e706
fix(sdk): remove every matching item in remove_list_unique
sgomezvillamor Dec 2, 2026
655939b
Merge remote-tracking branch 'origin/master' into feat-sdk-semanticmo…
sgomezvillamor Dec 2, 2026
d898cf5
Merge remote-tracking branch 'origin/feat-sdk-semanticmodels' into fe…
sgomezvillamor Dec 2, 2026
95f190c
fix(sdk): make remove_* a no-op when the aspect is not set locally
sgomezvillamor Dec 2, 2026
31233b5
docs(sdk): note derived_from rejects non-metric URNs; fix add_lineage…
sgomezvillamor Dec 2, 2026
d32a5db
docs: wrap the derived_from breaking-change entry
sgomezvillamor Dec 2, 2026
49e0b79
refactor(sdk): share one edge replace helper and the metric URN aliases
sgomezvillamor Dec 2, 2026
3be325b
test(sdk): cover metric lineage routes and drop message-wording checks
sgomezvillamor Dec 2, 2026
2ba33d1
fix(sdk): reading DataJob inlets/outlets no longer creates an empty l…
sgomezvillamor Dec 2, 2026
12f27d2
test(sdk): golden files for metric, semantic model and metric lineage
sgomezvillamor Dec 2, 2026
0c9cba3
docs(sdk): example for updating data job inlets and outlets
sgomezvillamor Dec 2, 2026
bbde868
Merge remote-tracking branch 'origin/feat-sdk-semanticmodels' into fe…
sgomezvillamor Dec 2, 2026
2c9740b
fix(sdk): write Metric fieldUpstreams only when there are columns or …
sgomezvillamor Dec 2, 2026
ca68719
fix(sdk): stamp edges added by the metric lineage routes
sgomezvillamor Dec 2, 2026
52b8115
Merge feat-sdk-semanticmodels into feat-dbt-cube-metric-column-lineage
sgomezvillamor Dec 2, 2026
4bf3cb5
fix(sdk): report only an unknown route as an unsupported lineage comb…
sgomezvillamor Dec 2, 2026
b169101
test(sdk): assert get_lineage strips unsupported fields on every server
sgomezvillamor Dec 2, 2026
41a4abb
fix(sdk): add metric lineage with patches instead of rewriting the as…
sgomezvillamor Dec 2, 2026
98ebdcf
docs(sdk): describe when Metric writes fieldUpstreams
sgomezvillamor Dec 2, 2026
e5c6e7a
fix(sdk): parse the dataset passed to Chart.remove_input_dataset
sgomezvillamor Dec 2, 2026
22fb161
docs: mention Metric entities as derived_from inputs in breaking changes
sgomezvillamor Dec 2, 2026
bc76258
docs(sdk): change inlets that exist in the data job update example
sgomezvillamor Dec 2, 2026
2e121c4
feat(sdk)!: return None from lineage getters when the aspect is unset
sgomezvillamor Dec 2, 2026
a66a5f6
refactor(sdk): take Metric upstream_fields as a list only
sgomezvillamor Dec 2, 2026
f65845f
feat(sdk): return None from Metric.upstream_datasets when unset
sgomezvillamor Dec 2, 2026
1c76de8
Merge remote-tracking branch 'origin/feat-sdk-semanticmodels' into fe…
sgomezvillamor Dec 2, 2026
b8f2592
revert(sdk): leave DataJob lineage changes for a follow-up
sgomezvillamor Dec 2, 2026
06d4b9d
docs: note Metric.upstream_datasets returns None when unset
sgomezvillamor Dec 2, 2026
973567d
fix(sdk): dedupe Metric.set_derived_from and keep existing entry stamps
sgomezvillamor Dec 2, 2026
45e5d25
fix(sdk): reject unsupported parent types in set_browse_path
sgomezvillamor Dec 2, 2026
cefca97
fix(sdk): validate the URN passed to remove_upstream_metric
sgomezvillamor Dec 2, 2026
c82a85f
docs(sdk): describe what each add_lineage route writes
sgomezvillamor Dec 2, 2026
04c5a8f
docs(sdk): list field structured properties as create-only on Semanti…
sgomezvillamor Dec 2, 2026
ed62ce3
test(sdk): check every Dashboard list setter keeps existing edge meta…
sgomezvillamor Dec 2, 2026
04f72ac
Merge remote-tracking branch 'origin/feat-sdk-semanticmodels' into fe…
sgomezvillamor Dec 2, 2026
9bf9551
fix(sdk): validate browse_path input in set_browse_path only
sgomezvillamor Dec 2, 2026
53db492
Merge remote-tracking branch 'origin/feat-sdk-semanticmodels' into fe…
sgomezvillamor Dec 2, 2026
dc20ed0
docs(sdk): clarify add_upstream_field parent edge and upstream_datase…
sgomezvillamor Dec 2, 2026
7f525b6
Merge branch 'feat-sdk-semanticmodels' into feat-dbt-cube-metric-colu…
sgomezvillamor Dec 2, 2026
229619b
docs(sdk): explain how to remove a logical dataset from a semantic model
sgomezvillamor Dec 3, 2026
8dbd7b5
fix(sdk): stop Metric from clearing lineage it was not given; add par…
sgomezvillamor Dec 3, 2026
f2ddaae
Merge branch 'feat-sdk-semanticmodels' into feat-dbt-cube-metric-colu…
sgomezvillamor Dec 3, 2026
9d6fb3a
fix(sdk): address Metric review findings
sgomezvillamor Dec 3, 2026
9436914
Merge branch 'feat-sdk-semanticmodels' into feat-dbt-cube-metric-colu…
sgomezvillamor Dec 3, 2026
e30a1a1
test(sdk): check the entity client sends the metric relationships patch
sgomezvillamor Dec 3, 2026
92d913d
Merge branch 'feat-sdk-semanticmodels' into feat-dbt-cube-metric-colu…
sgomezvillamor Dec 3, 2026
df34847
Merge branch 'master' into feat-sdk-semanticmodels
sgomezvillamor Dec 3, 2026
15c7f99
Merge remote-tracking branch 'origin/feat-sdk-semanticmodels' into fe…
sgomezvillamor Dec 3, 2026
cdd82df
fix(sdk): address remaining Metric review comments
sgomezvillamor Dec 3, 2026
d15c60f
Merge remote-tracking branch 'origin/feat-sdk-semanticmodels' into fe…
sgomezvillamor Dec 3, 2026
bb116db
Merge remote-tracking branch 'origin/master' into feat-dbt-cube-metri…
sgomezvillamor Dec 3, 2026
8a00a1f
Merge remote-tracking branch 'origin/master' into feat-dbt-cube-metri…
sgomezvillamor Dec 3, 2026
131f03d
fix(ingest/dbt,cube): honour include_column_lineage for metric column…
sgomezvillamor Dec 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion metadata-ingestion/docs/sources/cube/cube_post.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The connector extracts the following metadata:

Lineage is emitted when `include_lineage` is enabled (the default):

- **View to cube** — in dataset mode, views are linked to the cubes they are built on, including column-level lineage derived from each member's `aliasMember`. In semantic-model mode, that hop is `metric` → logical dataset → Cube dataset.
- **View to cube** — in dataset mode, views are linked to the cubes they are built on, including column-level lineage derived from each member's `aliasMember`. In semantic-model mode, that hop is `metric` → logical dataset → Cube dataset, and each metric also has column-level lineage to its measure's column on the logical dataset.
- **Cube to warehouse** — on Cube Cloud with the Metadata API, table and column references are read directly. On Cube Core, table-level lineage is parsed from each cube's SQL definition when `parse_sql_for_lineage` and `warehouse_platform` are set. Column-level lineage on Cube Core is best-effort: since `/v1/meta` does not expose per-member SQL, members are matched by name against the upstream table's columns as found in DataHub (so the warehouse must be ingested first, and members whose name differs from the underlying column — e.g. aggregate measures — are not linked).
- **Report and workbook to view** — on Cube Cloud, charts (reports) carry input lineage to the cubes/views in their query, and dashboards (workbooks) contain those charts, extending the chain to `warehouse → cube → view → chart → dashboard`. When `emit_semantic_model_entities` is true, a report that queried a view points at that view's logical datasets instead of a view dataset.

Expand Down
2 changes: 1 addition & 1 deletion metadata-ingestion/docs/sources/dbt/dbt_post.md
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ On top of the datasets described above, DataHub can also describe your dbt seman

- **One `semanticModel` per dbt project**, holding the join relationships between your semantic models. Its urn is `urn:li:semanticModel:(urn:li:dataPlatform:dbt,<project>,semantic_layer)`.
- **Semantic annotations on each semantic model's dataset.** The dataset keeps the urn, name, description, schema, subtype, tags, owners and lineage described above, and gains a link to its parent `semanticModel` plus a per-column annotation recording whether the column is a dimension or a measure, its aggregation function, and whether it is a time dimension.
- **One `metric` per measure with `create_metric: true`**, and one per top-level `metrics:` entry. Its urn is `urn:li:metric:(urn:li:dataPlatform:dbt,<project>,<metric_name>)`. Metrics carry an expression, a subtype naming dbt's metric type (`Simple`, `Ratio`, `Derived`, `Cumulative`, `Conversion`), upstream lineage to the datasets of the semantic models they read, and `derivedFrom` edges to the metrics they are built on.
- **One `metric` per measure with `create_metric: true`**, and one per top-level `metrics:` entry. Its urn is `urn:li:metric:(urn:li:dataPlatform:dbt,<project>,<metric_name>)`. Metrics carry an expression, a subtype naming dbt's metric type (`Simple`, `Ratio`, `Derived`, `Cumulative`, `Conversion`), upstream lineage to the datasets of the semantic models they read, column-level lineage to the measure columns they aggregate on those datasets, and `derivedFrom` edges to the metrics they are built on. A metric built on other metrics, such as a derived or ratio metric, also points at the measure columns of the metrics it builds on, as dbt lists them in the metric's input measures. A measure a metric names that cannot be matched to a measure column is left out of its column lineage and counted in the ingestion report.

Relationships follow MetricFlow's own join semantics: a semantic model that declares an entity as `foreign`, `unique` or `natural` joins to every semantic model that declares an entity of the **same name** as `primary`, `unique` or `natural`. When a key is declared in more than one semantic model, an edge is emitted to each - MetricFlow joins to each of them too. A reference to a key that is not in the ingested project is counted in the ingestion report rather than warned about, since that is normal when you filter part of a project.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
ERModelRelationshipCardinalityClass,
SemanticFieldTypeClass,
)
from datahub.metadata.urns import SemanticModelUrn
from datahub.metadata.urns import SchemaFieldUrn, SemanticModelUrn
from datahub.sdk.metric import Metric
from datahub.sdk.semantic_model import (
DialectExpressionInput,
Expand Down Expand Up @@ -379,6 +379,10 @@ def _metric(
description=member.description,
expression=expression,
upstream_datasets=[logical_urn],
# The `alias.member` the expression aggregates. The logical
# dataset's schema is built from these same cube members, so the
# field always exists there.
upstream_fields=[SchemaFieldUrn(logical_urn, member.name)],
Comment thread
sgomezvillamor marked this conversation as resolved.
Resolved
# Cube owns these metrics: [] clears stale metric-to-metric edges.
derived_from=[],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,9 @@ class DBTSourceReport(StaleEntityRemovalSourceReport, SemanticModelEmissionRepor
num_metrics_from_measures: int = 0
num_metrics_from_manifest: int = 0
num_metrics_without_upstreams: int = 0
# Measures a metric declares that resolve to no annotated measure column,
# so the metric carries no column-level lineage for them.
num_metric_upstream_fields_unresolved: int = 0
# Built but not emitted, because the SDK could not represent the entity.
# num_metrics_from_measures + num_metrics_from_manifest ==
# num_metrics_emitted + num_metrics_dropped.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ class _MetricComputation:

@dataclass(frozen=True)
class _MeasureLocation:
"""Where a measure lives, and how it aggregates."""
"""Where a measure lives, its column there, and how it aggregates."""

dataset_urn: str
field_path: str
expression: Optional[str]


Expand Down Expand Up @@ -867,6 +868,7 @@ def _index_measures(self, models: List[_PreparedModel]) -> _MeasureIndex:
key = measure.name.casefold()
location = _MeasureLocation(
dataset_urn=dataset_urn,
field_path=self._column_path(measure.name),
expression=self._measure_expression(measure, prepared.alias),
)
index.by_model.setdefault(prepared.node.dbt_name, {})[key] = location
Expand Down Expand Up @@ -1038,6 +1040,11 @@ def _metric_from_measure(
description=measure.description or None,
expression=expression,
upstream_datasets=[dataset_urn],
# The measure's own column, which the dbt path already emitted on
# this dataset: `measure` comes from `_AnnotatedFields.measures`.
upstream_fields=[
SchemaFieldUrn(dataset_urn, self._column_path(measure.name))
],
# A simple metric derives from no metric: [] clears stale edges.
derived_from=[],
extra_aspects=[
Expand All @@ -1058,10 +1065,12 @@ def _metric_from_definition(
)

upstreams: List[str] = []
measure_names = [
upstream_fields: List[SchemaFieldUrn] = []
declared_measure_names = [
measure_input.name for measure_input in metric_definition.measures
]
measure_names.extend(resolved.measure_names)
declared_folded = {name.casefold() for name in declared_measure_names}
measure_names = [*declared_measure_names, *resolved.measure_names]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Derived metrics are given direct column lineage from their transitive input_measures. Restrict measure-column resolution to metric types that directly aggregate measures; derived metrics should retain only their derivedFrom edges.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At metadata-ingestion/src/datahub/ingestion/source/dbt/dbt_semantic_model.py, line 1073:

<comment>Derived metrics are given direct column lineage from their transitive `input_measures`. Restrict measure-column resolution to metric types that directly aggregate measures; derived metrics should retain only their `derivedFrom` edges.</comment>

<file context>
@@ -1058,10 +1065,12 @@ def _metric_from_definition(
         ]
-        measure_names.extend(resolved.measure_names)
+        declared_folded = {name.casefold() for name in declared_measure_names}
+        measure_names = [*declared_measure_names, *resolved.measure_names]
         # A ratio's sides usually name other metrics, so they become derivedFrom
         # edges rather than measure references - but `_ratio_side` still renders
</file context>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changed: this is intentional. For a derived metric, a compiled dbt manifest lists in input_measures the measures of every metric it builds on, and those are the columns MetricFlow aggregates when it computes the metric, so the column edges describe what the metric reads. The derivedFrom edges to the metrics it builds on are kept as well. This is documented in dbt_post.md and covered by test_a_derived_metric_reads_the_columns_dbt_lists_as_its_input_measures. The human review raised the same question for the reviewer to decide, so I am leaving this thread open until that call is made.

# A ratio's sides usually name other metrics, so they become derivedFrom
# edges rather than measure references - but `_ratio_side` still renders
# each side as `agg(alias.measure)` whenever the name also resolves to a
Expand All @@ -1075,10 +1084,30 @@ def _metric_from_definition(
for side in (metric_definition.numerator, metric_definition.denominator)
if side is not None
)
# A dbt 1.6-style ratio over measures lists the same measure both in
# input_measures and as a ratio side; visit each name once so a missing
# measure is counted once.
seen_folded: Set[str] = set()
for measure_name in measure_names:
folded = measure_name.casefold()
if folded in seen_folded:
continue
seen_folded.add(folded)
located = self._locate_measure(metric_definition, index, measure_name)
if located and located.dataset_urn not in upstreams:
if located is None:
# Only a name dbt declares as a measure was expected to resolve:
# a ratio side that matches no measure names another metric,
# and is already a derivedFrom edge.
if folded in declared_folded:
self.report.num_metric_upstream_fields_unresolved += 1
continue
if located.dataset_urn not in upstreams:
upstreams.append(located.dataset_urn)
# Built from the field set the dataset annotation uses, so the
# column is one the dataset's schema carries.
field_urn = SchemaFieldUrn(located.dataset_urn, located.field_path)
if field_urn not in upstream_fields:
upstream_fields.append(field_urn)
for dbt_name in metric_definition.depends_on:
if not dbt_name.startswith(_SEMANTIC_MODEL_DEPENDS_ON_PREFIX):
continue
Expand All @@ -1100,6 +1129,9 @@ def _metric_from_definition(
description=metric_definition.description or None,
expression=self._metric_definition_expression(metric_definition, index),
upstream_datasets=upstreams,
# None when unresolved, so fieldUpstreams is left unset (the SDK
# default); the whole-aspect upsert clears stale edges either way.
upstream_fields=upstream_fields or None,
derived_from=resolved.metric_urns,
tags=[make_tag_urn(tag) for tag in metric_definition.tags] or None,
extra_aspects=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,11 @@
{
"destinationUrn": "urn:li:dataset:(urn:li:dataPlatform:cube,cube_demo.orders_view.orders,PROD)"
}
],
"fieldUpstreams": [
{
"destinationUrn": "urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:cube,cube_demo.orders_view.orders,PROD),count)"
}
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,11 @@
{
"destinationUrn": "urn:li:dataset:(urn:li:dataPlatform:dbt,project_a.semantic_model.project_a.orders,PROD)"
}
],
"fieldUpstreams": [
{
"destinationUrn": "urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:dbt,project_a.semantic_model.project_a.orders,PROD),order_total)"
}
]
}
},
Expand Down Expand Up @@ -3337,6 +3342,11 @@
{
"destinationUrn": "urn:li:dataset:(urn:li:dataPlatform:dbt,project_b.semantic_model.project_b.customers,PROD)"
}
],
"fieldUpstreams": [
{
"destinationUrn": "urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:dbt,project_b.semantic_model.project_b.customers,PROD),customer_count)"
}
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7993,6 +7993,14 @@
{
"destinationUrn": "urn:li:dataset:(urn:li:dataPlatform:dbt,semantic_model.sample_dbt.payments,PROD)"
}
],
"fieldUpstreams": [
{
"destinationUrn": "urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:dbt,semantic_model.sample_dbt.payments,PROD),payment_amount)"
},
{
"destinationUrn": "urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:dbt,semantic_model.sample_dbt.payments,PROD),payment_count)"
}
]
}
},
Expand Down Expand Up @@ -8259,6 +8267,11 @@
{
"destinationUrn": "urn:li:dataset:(urn:li:dataPlatform:dbt,semantic_model.sample_dbt.payments,PROD)"
}
],
"fieldUpstreams": [
{
"destinationUrn": "urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:dbt,semantic_model.sample_dbt.payments,PROD),payment_amount)"
}
]
}
},
Expand Down Expand Up @@ -8392,6 +8405,11 @@
{
"destinationUrn": "urn:li:dataset:(urn:li:dataPlatform:dbt,semantic_model.sample_dbt.payments,PROD)"
}
],
"fieldUpstreams": [
{
"destinationUrn": "urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:dbt,semantic_model.sample_dbt.payments,PROD),payment_amount)"
}
]
}
},
Expand Down Expand Up @@ -8525,6 +8543,11 @@
{
"destinationUrn": "urn:li:dataset:(urn:li:dataPlatform:dbt,semantic_model.sample_dbt.payments,PROD)"
}
],
"fieldUpstreams": [
{
"destinationUrn": "urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:dbt,semantic_model.sample_dbt.payments,PROD),payment_count)"
}
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8039,6 +8039,14 @@
{
"destinationUrn": "urn:li:dataset:(urn:li:dataPlatform:dbt,dbt-instance-1.semantic_model.sample_dbt.payments,PROD)"
}
],
"fieldUpstreams": [
{
"destinationUrn": "urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:dbt,dbt-instance-1.semantic_model.sample_dbt.payments,PROD),payment_amount)"
},
{
"destinationUrn": "urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:dbt,dbt-instance-1.semantic_model.sample_dbt.payments,PROD),payment_count)"
}
]
}
},
Expand Down Expand Up @@ -8315,6 +8323,11 @@
{
"destinationUrn": "urn:li:dataset:(urn:li:dataPlatform:dbt,dbt-instance-1.semantic_model.sample_dbt.payments,PROD)"
}
],
"fieldUpstreams": [
{
"destinationUrn": "urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:dbt,dbt-instance-1.semantic_model.sample_dbt.payments,PROD),payment_amount)"
}
]
}
},
Expand Down Expand Up @@ -8453,6 +8466,11 @@
{
"destinationUrn": "urn:li:dataset:(urn:li:dataPlatform:dbt,dbt-instance-1.semantic_model.sample_dbt.payments,PROD)"
}
],
"fieldUpstreams": [
{
"destinationUrn": "urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:dbt,dbt-instance-1.semantic_model.sample_dbt.payments,PROD),payment_amount)"
}
]
}
},
Expand Down Expand Up @@ -8591,6 +8609,11 @@
{
"destinationUrn": "urn:li:dataset:(urn:li:dataPlatform:dbt,dbt-instance-1.semantic_model.sample_dbt.payments,PROD)"
}
],
"fieldUpstreams": [
{
"destinationUrn": "urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:dbt,dbt-instance-1.semantic_model.sample_dbt.payments,PROD),payment_count)"
}
]
}
},
Expand Down
24 changes: 24 additions & 0 deletions metadata-ingestion/tests/unit/cube/test_cube_semantic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ContainerClass,
ERModelRelationshipCardinalityClass,
MetricInfoClass,
MetricUpstreamsClass,
NumberTypeClass,
SemanticModelInfoClass,
SemanticModelPropertiesClass,
Expand Down Expand Up @@ -225,6 +226,29 @@ def test_view_emits_semantic_model_metrics_and_logical_datasets() -> None:
assert mapper.report.semantic_model_datasets_emitted == 2


def test_metric_reads_its_member_column_on_the_logical_dataset() -> None:
mapper = _mapper()
cubes = {"orders": _orders_cube(), "customers": _customers_cube()}
aspects = _aspects_by_urn(list(mapper.emit(_orders_view(), cubes)))

orders_logical = (
"urn:li:dataset:(urn:li:dataPlatform:cube,demo.orders_view.orders,PROD)"
)
amount_metric = (
"urn:li:metric:(urn:li:dataPlatform:cube,demo.orders_view.orders,total_amount)"
)
upstreams = aspects[amount_metric]["MetricUpstreamsClass"]
assert isinstance(upstreams, MetricUpstreamsClass)
assert upstreams.fieldUpstreams is not None
assert [edge.destinationUrn for edge in upstreams.fieldUpstreams] == [
f"urn:li:schemaField:({orders_logical},total_amount)"
]
assert upstreams.datasetUpstreams is not None
assert [edge.destinationUrn for edge in upstreams.datasetUpstreams] == [
orders_logical
]


@pytest.mark.parametrize("platform_instance", [None, "prod_cube"])
def test_semantic_model_is_browsed_under_deployment_without_container_aspect(
platform_instance: Optional[str],
Expand Down
Loading