diff --git a/metricflow/model/semantics/linkable_spec_resolver.py b/metricflow/model/semantics/linkable_spec_resolver.py index 61541666b9..ad48a54430 100644 --- a/metricflow/model/semantics/linkable_spec_resolver.py +++ b/metricflow/model/semantics/linkable_spec_resolver.py @@ -120,8 +120,14 @@ def element_name(self) -> str: # noqa: D102 return self.reference.element_name @property - def path_key(self) -> ElementPathKey: # noqa: D102 - return ElementPathKey(element_name=self.element_name, entity_links=self.join_path.entity_links) + def path_key(self) -> ElementPathKey: + """Key that can uniquely identify an element and the joins used to realize the element. + + Use qualified name to guarantee uniqueness. + """ + return ElementPathKey( + element_name=self.as_group_by_metric_spec.qualified_name, entity_links=self.join_path.entity_links + ) @property def reference(self) -> MetricReference: # noqa: D102 @@ -142,6 +148,15 @@ def metric_subquery_entity_links(self) -> Tuple[EntityReference, ...]: metric_subquery = self.join_path.metric_subquery_join_path_element return metric_subquery.entity_links + (metric_subquery.join_on_entity,) + @property + def as_group_by_metric_spec(self) -> GroupByMetricSpec: + """Convert LinkableMetric to GroupByMetricSpec.""" + return GroupByMetricSpec( + element_name=self.element_name, + entity_links=self.join_path.entity_links, + metric_subquery_entity_links=self.metric_subquery_entity_links, + ) + @dataclass(frozen=True) class LinkableElementSet: