diff --git a/metricflow/engine/models.py b/metricflow/engine/models.py index cefbf73e85..542ca4bb75 100644 --- a/metricflow/engine/models.py +++ b/metricflow/engine/models.py @@ -109,10 +109,7 @@ def granularity_free_qualified_name(self) -> str: Dimension set has de-duplicated TimeDimensions such that you never have more than one granularity in your set for each TimeDimension. """ - parsed_name = StructuredLinkableSpecName.from_name(qualified_name=self.qualified_name) - return StructuredLinkableSpecName( - entity_link_names=parsed_name.entity_link_names, element_name=self.name - ).qualified_name + return StructuredLinkableSpecName.from_name(qualified_name=self.qualified_name).granularity_free_qualified_name @dataclass(frozen=True) diff --git a/metricflow/naming/linkable_spec_name.py b/metricflow/naming/linkable_spec_name.py index e2eeed0d7c..27fa92416b 100644 --- a/metricflow/naming/linkable_spec_name.py +++ b/metricflow/naming/linkable_spec_name.py @@ -91,3 +91,17 @@ def entity_prefix(self) -> Optional[str]: def date_part_suffix(date_part: DatePart) -> str: """Suffix used for names with a date_part.""" return f"extract_{date_part.value}" + + @property + def granularity_free_qualified_name(self) -> str: + """Renders the qualified name without the granularity suffix. + + In the list metrics and list dimensions outputs we want to render the qualified name of the dimension, but + without including the base granularity for time dimensions. This method is useful in those contexts. + Note: in most cases you should be using the qualified_name - this is only useful in cases where the + Dimension set has de-duplicated TimeDimensions such that you never have more than one granularity + in your set for each TimeDimension. + """ + return StructuredLinkableSpecName( + entity_link_names=self.entity_link_names, element_name=self.element_name + ).qualified_name