From d8043dd7fc40494ebe69b009c9c4bb9a10ac024a Mon Sep 17 00:00:00 2001 From: Devon Fulcher Date: Tue, 12 Sep 2023 10:33:51 -0500 Subject: [PATCH] fixed where filter object inheritance --- metricflow/specs/query_interface.py | 1 + metricflow/specs/where_filter_entity.py | 14 +++----------- metricflow/specs/where_filter_time_dimension.py | 14 +++----------- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/metricflow/specs/query_interface.py b/metricflow/specs/query_interface.py index ee55a52086..985d844ecf 100644 --- a/metricflow/specs/query_interface.py +++ b/metricflow/specs/query_interface.py @@ -28,6 +28,7 @@ def grain(self) -> Optional[TimeGranularity]: raise NotImplementedError + class QueryInterfaceDimension(Protocol): """Represents the interface for Dimension in the query interface.""" diff --git a/metricflow/specs/where_filter_entity.py b/metricflow/specs/where_filter_entity.py index 5631fb669e..83c983fd39 100644 --- a/metricflow/specs/where_filter_entity.py +++ b/metricflow/specs/where_filter_entity.py @@ -12,28 +12,20 @@ from typing_extensions import override from metricflow.specs.column_assoc import ColumnAssociationResolver -from metricflow.specs.query_interface import QueryInterfaceDimension, QueryInterfaceEntityFactory +from metricflow.specs.query_interface import QueryInterfaceEntity, QueryInterfaceEntityFactory from metricflow.specs.specs import EntitySpec -class WhereFilterEntity(ProtocolHint[QueryInterfaceDimension]): +class WhereFilterEntity(ProtocolHint[QueryInterfaceEntity]): """An entity that is passed in through the where filter parameter.""" @override - def _implements_protocol(self) -> QueryInterfaceDimension: + def _implements_protocol(self) -> QueryInterfaceEntity: return self def __init__(self, column_name: str): # noqa self.column_name = column_name - def grain(self, _grain: str) -> WhereFilterEntity: - """The time granularity.""" - raise NotImplementedError - - def alias(self, _alias: str) -> WhereFilterEntity: - """Renaming the column.""" - raise NotImplementedError - def __str__(self) -> str: """Returns the column name. diff --git a/metricflow/specs/where_filter_time_dimension.py b/metricflow/specs/where_filter_time_dimension.py index 18ed235a81..9ad0bb1826 100644 --- a/metricflow/specs/where_filter_time_dimension.py +++ b/metricflow/specs/where_filter_time_dimension.py @@ -10,28 +10,20 @@ from typing_extensions import override from metricflow.specs.column_assoc import ColumnAssociationResolver -from metricflow.specs.query_interface import QueryInterfaceDimension, QueryInterfaceTimeDimensionFactory +from metricflow.specs.query_interface import QueryInterfaceTimeDimension, QueryInterfaceTimeDimensionFactory from metricflow.specs.specs import TimeDimensionSpec -class WhereFilterTimeDimension(ProtocolHint[QueryInterfaceDimension]): +class WhereFilterTimeDimension(ProtocolHint[QueryInterfaceTimeDimension]): """A time dimension that is passed in through the where filter parameter.""" @override - def _implements_protocol(self) -> QueryInterfaceDimension: + def _implements_protocol(self) -> QueryInterfaceTimeDimension: return self def __init__(self, column_name: str): # noqa self.column_name = column_name - def grain(self, _grain: str) -> WhereFilterTimeDimension: - """The time granularity.""" - raise NotImplementedError - - def alias(self, _alias: str) -> WhereFilterTimeDimension: - """Renaming the column.""" - raise NotImplementedError - def __str__(self) -> str: """Returns the column name.