Skip to content

Commit

Permalink
Dedupe qualified name for GroupByMetricSpecs
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Apr 26, 2024
1 parent d5fd394 commit e6b9b7b
Show file tree
Hide file tree
Showing 3 changed files with 856 additions and 242 deletions.
17 changes: 17 additions & 0 deletions metricflow/specs/specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,23 @@ def metric_subquery_entity_spec(self) -> EntitySpec:
entity_links=self.metric_subquery_entity_links[:-1],
)

@property
def qualified_name(self) -> str:
"""Element name prefixed with entity links.
If same entity links are used in inner & outer query, use standard qualified name (country__bookings).
Else, specify both sets of entity links (listing__country__user__country__bookings).
"""
if self.entity_links == self.metric_subquery_entity_links:
entity_links = self.entity_links
else:
entity_links = self.entity_links + self.metric_subquery_entity_links

return StructuredLinkableSpecName(
entity_link_names=tuple(entity_link.element_name for entity_link in entity_links),
element_name=self.element_name,
).qualified_name

def __eq__(self, other: Any) -> bool: # type: ignore[misc] # noqa: D105
if not isinstance(other, GroupByMetricSpec):
return False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@
'metric_time__year',
'user',
'user__active_listings',
'user__bookings_per_listing',
'user__company',
'user__company__active_listings',
'user__company__current_account_balance_by_user',
Expand Down Expand Up @@ -331,6 +330,7 @@
'user__listing__user__bookings_join_to_time_spine',
'user__listing__user__bookings_per_booker',
'user__listing__user__bookings_per_dollar',
'user__listing__user__bookings_per_listing',
'user__listing__user__bookings_per_lux_listing_derived',
'user__listing__user__bookings_per_view',
'user__listing__user__derived_bookings_0',
Expand Down
Loading

0 comments on commit e6b9b7b

Please sign in to comment.