diff --git a/metricflow/engine/metricflow_engine.py b/metricflow/engine/metricflow_engine.py index 0d40776811..92a34ee25f 100644 --- a/metricflow/engine/metricflow_engine.py +++ b/metricflow/engine/metricflow_engine.py @@ -222,7 +222,9 @@ def explain( pass @abstractmethod - def simple_dimensions_for_metrics(self, metric_names: List[str]) -> List[Dimension]: + def simple_dimensions_for_metrics( + self, metric_names: List[str], without_any_property: Sequence[LinkableElementProperties] + ) -> List[Dimension]: """Retrieves a list of all common dimensions for metric_names. "simple" dimensions are the ones that people expect from a UI perspective. For example, if "ds" is a time @@ -230,6 +232,7 @@ def simple_dimensions_for_metrics(self, metric_names: List[str]) -> List[Dimensi Args: metric_names: Names of metrics to get common dimensions from. + without_any_property: Return dimensions not matching these properties. Returns: A list of Dimension objects containing metadata. @@ -491,17 +494,19 @@ def _create_execution_plan(self, mf_query_request: MetricFlowQueryRequest) -> Me def explain(self, mf_request: MetricFlowQueryRequest) -> MetricFlowExplainResult: # noqa: D return self._create_execution_plan(mf_request) - def simple_dimensions_for_metrics(self, metric_names: List[str]) -> List[Dimension]: # noqa: D + def simple_dimensions_for_metrics( # noqa: D + self, + metric_names: List[str], + without_any_property: Sequence[LinkableElementProperties] = ( + LinkableElementProperties.ENTITY, + LinkableElementProperties.DERIVED_TIME_GRANULARITY, + LinkableElementProperties.LOCAL_LINKED, + ), + ) -> List[Dimension]: path_key_to_linkable_dimensions = ( self._semantic_manifest_lookup.metric_lookup.linkable_set_for_metrics( metric_references=[MetricReference(element_name=mname) for mname in metric_names], - without_any_property=frozenset( - { - LinkableElementProperties.ENTITY, - LinkableElementProperties.DERIVED_TIME_GRANULARITY, - LinkableElementProperties.LOCAL_LINKED, - } - ), + without_any_property=frozenset(without_any_property), ) ).path_key_to_linkable_dimensions diff --git a/metricflow/engine/models.py b/metricflow/engine/models.py index ec05d5e262..2b07ba7700 100644 --- a/metricflow/engine/models.py +++ b/metricflow/engine/models.py @@ -3,6 +3,7 @@ from dataclasses import dataclass from typing import List, Optional, Sequence +from dbt_semantic_interfaces.implementations.elements.dimension import PydanticDimensionTypeParams from dbt_semantic_interfaces.protocols.dimension import ( Dimension as SemanticManifestDimension, ) @@ -78,12 +79,18 @@ def from_pydantic(cls, pydantic_dimension: SemanticManifestDimension, path_key: element_name=path_key.element_name, entity_links=path_key.entity_links, ).qualified_name + parsed_type_params: Optional[DimensionTypeParams] = None + if pydantic_dimension.type_params: + parsed_type_params = PydanticDimensionTypeParams( + time_granularity=path_key.time_granularity, + validity_params=pydantic_dimension.type_params.validity_params, + ) return cls( name=pydantic_dimension.name, qualified_name=qualified_name, description=pydantic_dimension.description, type=pydantic_dimension.type, - type_params=pydantic_dimension.type_params, + type_params=parsed_type_params, metadata=pydantic_dimension.metadata, is_partition=pydantic_dimension.is_partition, expr=pydantic_dimension.expr,