Skip to content

Commit

Permalink
temp commit
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamDee committed Dec 15, 2023
1 parent 50ea3fe commit 4bd6241
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions metricflow/model/semantics/linkable_spec_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,8 @@ def __init__(
), "A conversion metric should have type_params.conversion_type_params defined."
if measure == conversion_type_params.base_measure.measure_reference:
# Only can query against the base measure's linkable elements
# as it joins everything back to the base measure data set so
# there is no way of getting the conversion elements
linkable_sets_for_measure.append(self._get_linkable_element_set_for_measure(measure))
else:
assert_values_exhausted(metric.type)
Expand Down
18 changes: 10 additions & 8 deletions metricflow/model/semantics/semantic_model_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def __init__( # noqa: D
self._entity_ref_to_entity: Dict[EntityReference, Optional[str]] = {}
self._semantic_model_names: Set[str] = set()

self._dimension_name_to_spec: Dict[str, DimensionSpec] = {}
self._entity_name_to_spec: Dict[str, EntitySpec] = {}
self._dimension_ref_to_spec: Dict[DimensionReference, DimensionSpec] = {}
self._entity_ref_to_spec: Dict[EntityReference, EntitySpec] = {}

self._semantic_model_to_aggregation_time_dimensions: Dict[
SemanticModelReference, ElementGrouper[TimeDimensionReference, MeasureSpec]
Expand Down Expand Up @@ -252,7 +252,7 @@ def _add_semantic_model(self, semantic_model: SemanticModel) -> None:
for dim in semantic_model.dimensions:
self._linkable_reference_index[dim.reference].append(semantic_model)
self._dimension_index[dim.reference].append(semantic_model)
self._dimension_name_to_spec[dim.name] = (
self._dimension_ref_to_spec[dim.time_dimension_reference or dim.reference] = (
TimeDimensionSpec.from_name(dim.name)
if dim.type is DimensionType.TIME
else DimensionSpec.from_name(dim.name)
Expand All @@ -262,7 +262,7 @@ def _add_semantic_model(self, semantic_model: SemanticModel) -> None:
self._entity_ref_to_entity[entity.reference] = entity.name
self._entity_index[entity.name].append(semantic_model)
self._linkable_reference_index[entity.reference].append(semantic_model)
self._entity_name_to_spec[entity.name] = EntitySpec.from_name(entity.name)
self._entity_ref_to_spec[entity.reference] = EntitySpec.from_name(entity.name)

self._semantic_model_reference_to_semantic_model[semantic_model.reference] = semantic_model

Expand Down Expand Up @@ -339,9 +339,11 @@ def entity_links_for_local_elements(semantic_model: SemanticModel) -> Sequence[E
return sorted(possible_entity_links, key=lambda entity_reference: entity_reference.element_name)

def get_element_spec_for_name(self, element_name: str) -> LinkableInstanceSpec: # noqa: D
if element_name in self._dimension_name_to_spec:
return self._dimension_name_to_spec[element_name]
elif element_name in self._entity_name_to_spec:
return self._entity_name_to_spec[element_name]
if TimeDimensionReference(element_name=element_name) in self._dimension_ref_to_spec:
return self._dimension_ref_to_spec[TimeDimensionReference(element_name=element_name)]
elif DimensionReference(element_name=element_name) in self._dimension_ref_to_spec:
return self._dimension_ref_to_spec[DimensionReference(element_name=element_name)]
elif EntityReference(element_name=element_name) in self._entity_ref_to_spec:
return self._entity_ref_to_spec[EntityReference(element_name=element_name)]
else:
raise ValueError(f"Unable to find linkable element {element_name} in manifest")

0 comments on commit 4bd6241

Please sign in to comment.