Skip to content

Commit

Permalink
Move logic for directly linkable metrics to _get_joined_elements (sem…
Browse files Browse the repository at this point in the history
…antics)
  • Loading branch information
courtneyholcomb committed Apr 18, 2024
1 parent ecbb5e9 commit 5b9210d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions metricflow/model/semantics/linkable_spec_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,8 @@ def _get_metric_time_elements(self, measure_reference: Optional[MeasureReference

def _get_joined_elements(self, measure_semantic_model: SemanticModel) -> LinkableElementSet:
"""Get the elements that can be generated by joining other models to the given model."""
directly_linkable_metrics = self._get_joinable_metrics_for_semantic_model(semantic_model=measure_semantic_model)

# Create single-hop elements
join_paths = []
for entity in measure_semantic_model.entities:
Expand Down Expand Up @@ -885,7 +887,9 @@ def _get_joined_elements(self, measure_semantic_model: SemanticModel) -> Linkabl
)
join_paths = new_join_paths

return LinkableElementSet.merge_by_path_key((single_hop_elements, multi_hop_elements))
return LinkableElementSet.merge_by_path_key(
(directly_linkable_metrics, single_hop_elements, multi_hop_elements)
)

def _get_linkable_element_set_for_measure(
self,
Expand All @@ -897,17 +901,11 @@ def _get_linkable_element_set_for_measure(
measure_semantic_model = self._get_semantic_model_for_measure(measure_reference)

elements_in_semantic_model = self._get_elements_in_semantic_model(measure_semantic_model)
metrics_linked_to_semantic_model = self._get_joinable_metrics_for_semantic_model(measure_semantic_model)
metric_time_elements = self._get_metric_time_elements(measure_reference)
joined_elements = self._get_joined_elements(measure_semantic_model)

return LinkableElementSet.merge_by_path_key(
(
elements_in_semantic_model,
metrics_linked_to_semantic_model,
metric_time_elements,
joined_elements,
)
(elements_in_semantic_model, metric_time_elements, joined_elements)
).filter(
with_any_of=with_any_of,
without_any_of=without_any_of,
Expand Down

0 comments on commit 5b9210d

Please sign in to comment.