Skip to content

Commit

Permalink
Expose granularity_free_qualified_name on `StructuredLinkableSpecNa…
Browse files Browse the repository at this point in the history
…me` (#781)

Expose granularity_free_qualified_name on StructuredLinkableSpecName
  • Loading branch information
courtneyholcomb authored Sep 23, 2023
1 parent 47042ca commit 175dbda
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 1 addition & 4 deletions metricflow/engine/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions metricflow/naming/linkable_spec_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 175dbda

Please sign in to comment.