From cc61b1cff74f627b11b75b0f7ce2193d9a1240c5 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Mon, 9 Oct 2023 18:19:55 -0700 Subject: [PATCH] Delete unneeded changes --- .../dataflow/builder/dataflow_plan_builder.py | 58 +------------------ .../model/semantics/semantic_model_lookup.py | 6 -- metricflow/protocols/semantics.py | 7 --- 3 files changed, 1 insertion(+), 70 deletions(-) diff --git a/metricflow/dataflow/builder/dataflow_plan_builder.py b/metricflow/dataflow/builder/dataflow_plan_builder.py index 3099bac0fc..145783ff5f 100644 --- a/metricflow/dataflow/builder/dataflow_plan_builder.py +++ b/metricflow/dataflow/builder/dataflow_plan_builder.py @@ -9,10 +9,7 @@ from dbt_semantic_interfaces.enum_extension import assert_values_exhausted from dbt_semantic_interfaces.pretty_print import pformat_big_objects from dbt_semantic_interfaces.protocols.metric import MetricTimeWindow, MetricType -from dbt_semantic_interfaces.protocols.semantic_model import SemanticModel from dbt_semantic_interfaces.references import ( - DimensionReference, - EntityReference, TimeDimensionReference, ) from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity @@ -305,67 +302,14 @@ def _build_metrics_output_node( join_type=combine_metrics_join_type, ) - def __get_semantic_models_for_linkable_specs( - self, linkable_specs: LinkableSpecSet - ) -> Dict[SemanticModel, LinkableSpecSet]: - """Build dict of semantic models to associated linkable specs.""" - semantic_models_to_linkable_specs: Dict[SemanticModel, LinkableSpecSet] = {} - - # Dimensions - for dimension_spec in linkable_specs.dimension_specs: - semantic_models = self._semantic_model_lookup.get_semantic_models_for_linkable_element( - linkable_element=DimensionReference(element_name=dimension_spec.element_name) - ) - for semantic_model in semantic_models: - new_linkable_spec_set = LinkableSpecSet(dimension_specs=(dimension_spec,)) - linkable_specs_for_semantic_model = semantic_models_to_linkable_specs.get(semantic_model) - semantic_models_to_linkable_specs[semantic_model] = ( - LinkableSpecSet.merge([linkable_specs_for_semantic_model, new_linkable_spec_set]) - if linkable_specs_for_semantic_model - else new_linkable_spec_set - ) - # Time dimensions - for time_dimension_spec in linkable_specs.time_dimension_specs: - semantic_models = self._semantic_model_lookup.get_semantic_models_for_linkable_element( - linkable_element=TimeDimensionReference(element_name=time_dimension_spec.element_name) - ) - for semantic_model in semantic_models: - new_linkable_spec_set = LinkableSpecSet(time_dimension_specs=(time_dimension_spec,)) - semantic_models_to_linkable_specs[semantic_model] = ( - LinkableSpecSet.merge([linkable_specs_for_semantic_model, new_linkable_spec_set]) - if linkable_specs_for_semantic_model - else new_linkable_spec_set - ) - # Entities - for entity_spec in linkable_specs.entity_specs: - semantic_models = self._semantic_model_lookup.get_semantic_models_for_linkable_element( - linkable_element=EntityReference(element_name=entity_spec.element_name) - ) - for semantic_model in semantic_models: - new_linkable_spec_set = LinkableSpecSet(entity_specs=(entity_spec,)) - semantic_models_to_linkable_specs[semantic_model] = ( - LinkableSpecSet.merge([linkable_specs_for_semantic_model, new_linkable_spec_set]) - if linkable_specs_for_semantic_model - else new_linkable_spec_set - ) - - return semantic_models_to_linkable_specs - def build_plan_for_distinct_values(self, query_spec: MetricFlowQuerySpec) -> DataflowPlan: """Generate a plan that would get the distinct values of a linkable instance. e.g. distinct listing__country_latest for bookings by listing__country_latest """ assert not query_spec.metric_specs, "Can't build distinct values plan with metrics." - # linkable_specs_to_dataflow_recipes: Dict[LinkableSpecSet, DataflowRecipe] = {} - # for linkable_specs in self.__get_semantic_models_for_linkable_specs( - # linkable_specs=query_spec.linkable_specs - # ).values(): - dataflow_recipe = self._find_dataflow_recipe(linkable_spec_set=query_spec.linkable_specs) - if not dataflow_recipe: - raise UnableToSatisfyQueryError(f"Recipe not found for linkable specs: {query_spec.linkable_specs}.") - # linkable_specs_to_dataflow_recipes[linkable_specs] = dataflow_recipe + dataflow_recipe = self._find_dataflow_recipe(linkable_spec_set=query_spec.linkable_specs) if not dataflow_recipe: raise UnableToSatisfyQueryError(f"Recipe not found for linkable specs: {query_spec.linkable_specs}") diff --git a/metricflow/model/semantics/semantic_model_lookup.py b/metricflow/model/semantics/semantic_model_lookup.py index 44d8ba0a03..7c459949cd 100644 --- a/metricflow/model/semantics/semantic_model_lookup.py +++ b/metricflow/model/semantics/semantic_model_lookup.py @@ -268,12 +268,6 @@ def get_semantic_models_for_entity(self, entity_reference: EntityReference) -> S entity = self._entity_ref_to_entity[entity_reference] return set(self._entity_index[entity]) - def get_semantic_models_for_linkable_element( - self, linkable_element: LinkableElementReference - ) -> Set[SemanticModel]: - """Return all semantic models associated with a linkable element reference.""" - return set(self._linkable_reference_index[linkable_element]) - @staticmethod def get_entity_from_semantic_model( semantic_model: SemanticModel, entity_reference: LinkableElementReference diff --git a/metricflow/protocols/semantics.py b/metricflow/protocols/semantics.py index 8ba4833d4e..6fc4e00a39 100644 --- a/metricflow/protocols/semantics.py +++ b/metricflow/protocols/semantics.py @@ -19,7 +19,6 @@ from dbt_semantic_interfaces.references import ( DimensionReference, EntityReference, - LinkableElementReference, MeasureReference, MetricReference, SemanticModelElementReference, @@ -102,12 +101,6 @@ def get_entity_in_semantic_model(self, ref: SemanticModelElementReference) -> Op """Retrieve the entity matching the element -> semantic model mapping, if any.""" raise NotImplementedError - def get_semantic_models_for_linkable_element( - self, linkable_element: LinkableElementReference - ) -> Set[SemanticModel]: - """Return all semantic models associated with a linkable element reference.""" - raise NotImplementedError - @abstractmethod def get_by_reference(self, semantic_model_reference: SemanticModelReference) -> Optional[SemanticModel]: """Retrieve the semantic model object matching the input semantic model reference, if any."""