Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose granularity_free_qualified_name on StructuredLinkableSpecName #781

Merged
merged 1 commit into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading