diff --git a/.changes/unreleased/Fixes-20230926-140015.yaml b/.changes/unreleased/Fixes-20230926-140015.yaml new file mode 100644 index 0000000000..339de9012e --- /dev/null +++ b/.changes/unreleased/Fixes-20230926-140015.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Removing methods and reordering parameters for Query Interface. +time: 2023-09-26T14:00:15.741015-05:00 +custom: + Author: DevonFulcher + Issue: None diff --git a/metricflow/protocols/query_interface.py b/metricflow/protocols/query_interface.py index ec120699c9..2831740ba4 100644 --- a/metricflow/protocols/query_interface.py +++ b/metricflow/protocols/query_interface.py @@ -1,33 +1,35 @@ from __future__ import annotations +from abc import abstractmethod from typing import Optional, Protocol, Sequence class QueryInterfaceMetric(Protocol): """Represents the interface for Metric in the query interface.""" + @abstractmethod def descending(self, _is_descending: bool) -> QueryInterfaceMetric: """Set the sort order for order-by.""" - raise NotImplementedError + pass class QueryInterfaceDimension(Protocol): """Represents the interface for Dimension in the query interface.""" + @abstractmethod def grain(self, _grain: str) -> QueryInterfaceDimension: """The time granularity.""" - raise NotImplementedError - - def alias(self, _alias: str) -> QueryInterfaceDimension: - """Renaming the column.""" - raise NotImplementedError + pass + @abstractmethod def descending(self, _is_descending: bool) -> QueryInterfaceDimension: """Set the sort order for order-by.""" + pass + @abstractmethod def date_part(self, _date_part: str) -> QueryInterfaceDimension: """Date part to extract from the dimension.""" - raise NotImplementedError + pass class QueryInterfaceDimensionFactory(Protocol): @@ -36,9 +38,10 @@ class QueryInterfaceDimensionFactory(Protocol): Represented as the Dimension constructor in the Jinja sandbox. """ + @abstractmethod def create(self, name: str, entity_path: Sequence[str] = ()) -> QueryInterfaceDimension: """Create a QueryInterfaceDimension.""" - raise NotImplementedError + pass class QueryInterfaceTimeDimension(Protocol): @@ -53,24 +56,23 @@ class QueryInterfaceTimeDimensionFactory(Protocol): Represented as the TimeDimension constructor in the Jinja sandbox. """ + @abstractmethod def create( self, time_dimension_name: str, time_granularity_name: str, - descending: bool = False, - date_part_name: Optional[str] = None, entity_path: Sequence[str] = (), + descending: Optional[bool] = None, + date_part_name: Optional[str] = None, ) -> QueryInterfaceTimeDimension: """Create a TimeDimension.""" - raise NotImplementedError + pass class QueryInterfaceEntity(Protocol): """Represents the interface for Entity in the query interface.""" - def descending(self, _is_descending: bool) -> QueryInterfaceEntity: - """Set the sort order for order-by.""" - raise NotImplementedError + pass class QueryInterfaceEntityFactory(Protocol): @@ -79,6 +81,7 @@ class QueryInterfaceEntityFactory(Protocol): Represented as the Entity constructor in the Jinja sandbox. """ + @abstractmethod def create(self, entity_name: str, entity_path: Sequence[str] = ()) -> QueryInterfaceEntity: """Create an Entity.""" - raise NotImplementedError + pass diff --git a/metricflow/specs/where_filter_time_dimension.py b/metricflow/specs/where_filter_time_dimension.py index 6dd2bf7388..0ed4fceea5 100644 --- a/metricflow/specs/where_filter_time_dimension.py +++ b/metricflow/specs/where_filter_time_dimension.py @@ -56,15 +56,17 @@ def create( self, time_dimension_name: str, time_granularity_name: str, - descending: bool = False, - date_part_name: Optional[str] = None, entity_path: Sequence[str] = (), + descending: Optional[bool] = None, + date_part_name: Optional[str] = None, ) -> WhereFilterTimeDimension: """Create a WhereFilterTimeDimension.""" if descending: raise InvalidQuerySyntax( "Can't set descending in the where clause. Try setting descending in the order_by clause instead" ) + if date_part_name: + raise InvalidQuerySyntax("date_part_name isn't currently supported in the where parameter") structured_name = DunderedNameFormatter.parse_name(time_dimension_name) call_parameter_set = TimeDimensionCallParameterSet( time_dimension_reference=TimeDimensionReference(element_name=structured_name.element_name),