diff --git a/metricflow/model/semantics/linkable_spec_resolver.py b/metricflow/model/semantics/linkable_spec_resolver.py index f12ab6075b..c10fb5444e 100644 --- a/metricflow/model/semantics/linkable_spec_resolver.py +++ b/metricflow/model/semantics/linkable_spec_resolver.py @@ -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: @@ -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, @@ -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,