Skip to content

Commit

Permalink
Delete unneeded changes
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Oct 10, 2023
1 parent b986d60 commit cc61b1c
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 70 deletions.
58 changes: 1 addition & 57 deletions metricflow/dataflow/builder/dataflow_plan_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}")

Expand Down
6 changes: 0 additions & 6 deletions metricflow/model/semantics/semantic_model_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions metricflow/protocols/semantics.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from dbt_semantic_interfaces.references import (
DimensionReference,
EntityReference,
LinkableElementReference,
MeasureReference,
MetricReference,
SemanticModelElementReference,
Expand Down Expand Up @@ -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."""
Expand Down

0 comments on commit cc61b1c

Please sign in to comment.