Skip to content

Commit

Permalink
Add StructuredLinkableSpecName.entity_links property
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamDee committed Nov 12, 2024
1 parent 7c0f846 commit 0bc036e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from functools import lru_cache
from typing import Optional, Sequence, Tuple

from dbt_semantic_interfaces.references import EntityReference
from dbt_semantic_interfaces.type_enums.date_part import DatePart
from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity

Expand Down Expand Up @@ -106,6 +107,11 @@ def date_part_suffix(date_part: DatePart) -> str:
"""Suffix used for names with a date_part."""
return f"extract_{date_part.value}"

@property
def entity_links(self) -> Tuple[EntityReference, ...]:
"""Returns the entity link references."""
return tuple(EntityReference(entity_link_name.lower()) for entity_link_name in self.entity_link_names)

@property
def granularity_free_qualified_name(self) -> str:
"""Renders the qualified name without the granularity suffix.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,5 @@ def create(self, name: str, entity_path: Sequence[str] = ()) -> WhereFilterDimen
rendered_spec_tracker=self._rendered_spec_tracker,
element_name=structured_name.element_name,
entity_links=tuple(EntityReference(entity_link_name.lower()) for entity_link_name in entity_path)
+ tuple(
EntityReference(entity_link_name.lower()) for entity_link_name in structured_name.entity_link_names
),
+ structured_name.entity_links,
)
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,5 @@ def create(self, entity_name: str, entity_path: Sequence[str] = ()) -> WhereFilt
rendered_spec_tracker=self._rendered_spec_tracker,
element_name=structured_name.element_name,
entity_links=tuple(EntityReference(entity_link_name.lower()) for entity_link_name in entity_path)
+ tuple(
EntityReference(entity_link_name.lower()) for entity_link_name in structured_name.entity_link_names
),
+ structured_name.entity_links,
)

0 comments on commit 0bc036e

Please sign in to comment.