Skip to content

Commit

Permalink
Use helper properties
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Apr 15, 2024
1 parent 735a451 commit 7d7d163
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions metricflow/model/semantics/linkable_spec_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,8 +1026,6 @@ def create_linkable_element_set_from_join_path(
with_properties: FrozenSet[LinkableElementProperty],
) -> LinkableElementSet:
"""Given the current path, generate the respective linkable elements from the last semantic model in the path."""
entity_links = tuple(x.join_on_entity for x in join_path.path_elements)

semantic_model = self._semantic_model_lookup.get_by_reference(join_path.last_semantic_model_reference)
assert semantic_model

Expand All @@ -1042,7 +1040,7 @@ def create_linkable_element_set_from_join_path(
LinkableDimension(
semantic_model_origin=semantic_model.reference,
element_name=dimension.reference.element_name,
entity_links=entity_links,
entity_links=join_path.entity_links,
join_path=join_path.path_elements,
properties=with_properties,
time_granularity=None,
Expand All @@ -1054,7 +1052,7 @@ def create_linkable_element_set_from_join_path(
_generate_linkable_time_dimensions(
semantic_model_origin=semantic_model.reference,
dimension=dimension,
entity_links=entity_links,
entity_links=join_path.entity_links,
join_path=join_path.path_elements,
with_properties=with_properties,
)
Expand All @@ -1064,12 +1062,12 @@ def create_linkable_element_set_from_join_path(

for entity in semantic_model.entities:
# Avoid creating "booking_id__booking_id"
if entity.reference != entity_links[-1]:
if entity.reference != join_path.last_entity_link:
linkable_entities.append(
LinkableEntity(
semantic_model_origin=semantic_model.reference,
element_name=entity.reference.element_name,
entity_links=entity_links,
entity_links=join_path.entity_links,
join_path=join_path.path_elements,
properties=with_properties.union({LinkableElementProperty.ENTITY}),
)
Expand All @@ -1078,7 +1076,7 @@ def create_linkable_element_set_from_join_path(
linkable_metrics = [
LinkableMetric(
element_name=metric.element_name,
entity_links=entity_links,
entity_links=join_path.entity_links,
join_path=join_path.path_elements,
join_by_semantic_model=semantic_model.reference,
properties=with_properties.union({LinkableElementProperty.METRIC}),
Expand Down

0 comments on commit 7d7d163

Please sign in to comment.