From 39ecb395fb2745f5faaa1ecab413b041622d1591 Mon Sep 17 00:00:00 2001 From: Devon Fulcher Date: Fri, 6 Oct 2023 17:09:43 -0500 Subject: [PATCH] removed query interface --- .../Under the Hood-20231006-170905.yaml | 6 ++ metricflow/protocols/query_interface.py | 87 ------------------- metricflow/specs/where_filter_dimension.py | 8 +- metricflow/specs/where_filter_entity.py | 2 +- .../specs/where_filter_time_dimension.py | 5 +- 5 files changed, 15 insertions(+), 93 deletions(-) create mode 100644 .changes/unreleased/Under the Hood-20231006-170905.yaml delete mode 100644 metricflow/protocols/query_interface.py diff --git a/.changes/unreleased/Under the Hood-20231006-170905.yaml b/.changes/unreleased/Under the Hood-20231006-170905.yaml new file mode 100644 index 0000000000..9fad8d4487 --- /dev/null +++ b/.changes/unreleased/Under the Hood-20231006-170905.yaml @@ -0,0 +1,6 @@ +kind: Under the Hood +body: Remove query interface and depend on DSI protocol instead +time: 2023-10-06T17:09:05.593372-05:00 +custom: + Author: DevonFulcher + Issue: None diff --git a/metricflow/protocols/query_interface.py b/metricflow/protocols/query_interface.py deleted file mode 100644 index 2831740ba4..0000000000 --- a/metricflow/protocols/query_interface.py +++ /dev/null @@ -1,87 +0,0 @@ -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.""" - pass - - -class QueryInterfaceDimension(Protocol): - """Represents the interface for Dimension in the query interface.""" - - @abstractmethod - def grain(self, _grain: str) -> QueryInterfaceDimension: - """The time granularity.""" - 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.""" - pass - - -class QueryInterfaceDimensionFactory(Protocol): - """Creates a Dimension for the query interface. - - Represented as the Dimension constructor in the Jinja sandbox. - """ - - @abstractmethod - def create(self, name: str, entity_path: Sequence[str] = ()) -> QueryInterfaceDimension: - """Create a QueryInterfaceDimension.""" - pass - - -class QueryInterfaceTimeDimension(Protocol): - """Represents the interface for TimeDimension in the query interface.""" - - pass - - -class QueryInterfaceTimeDimensionFactory(Protocol): - """Creates a TimeDimension for the query interface. - - Represented as the TimeDimension constructor in the Jinja sandbox. - """ - - @abstractmethod - def create( - self, - time_dimension_name: str, - time_granularity_name: str, - entity_path: Sequence[str] = (), - descending: Optional[bool] = None, - date_part_name: Optional[str] = None, - ) -> QueryInterfaceTimeDimension: - """Create a TimeDimension.""" - pass - - -class QueryInterfaceEntity(Protocol): - """Represents the interface for Entity in the query interface.""" - - pass - - -class QueryInterfaceEntityFactory(Protocol): - """Creates an Entity for the query interface. - - Represented as the Entity constructor in the Jinja sandbox. - """ - - @abstractmethod - def create(self, entity_name: str, entity_path: Sequence[str] = ()) -> QueryInterfaceEntity: - """Create an Entity.""" - pass diff --git a/metricflow/specs/where_filter_dimension.py b/metricflow/specs/where_filter_dimension.py index 52720870a9..9af2858d8f 100644 --- a/metricflow/specs/where_filter_dimension.py +++ b/metricflow/specs/where_filter_dimension.py @@ -6,14 +6,14 @@ FilterCallParameterSets, ) from dbt_semantic_interfaces.protocols.protocol_hint import ProtocolHint +from dbt_semantic_interfaces.protocols.query_interface import ( + QueryInterfaceDimension, + QueryInterfaceDimensionFactory, +) from dbt_semantic_interfaces.type_enums import TimeGranularity from typing_extensions import override from metricflow.errors.errors import InvalidQuerySyntax -from metricflow.protocols.query_interface import ( - QueryInterfaceDimension, - QueryInterfaceDimensionFactory, -) from metricflow.specs.column_assoc import ColumnAssociationResolver from metricflow.specs.dimension_spec_resolver import DimensionSpecResolver from metricflow.specs.specs import TimeDimensionSpec diff --git a/metricflow/specs/where_filter_entity.py b/metricflow/specs/where_filter_entity.py index 78af16c458..2dd893f7d7 100644 --- a/metricflow/specs/where_filter_entity.py +++ b/metricflow/specs/where_filter_entity.py @@ -8,11 +8,11 @@ ) from dbt_semantic_interfaces.naming.dundered import DunderedNameFormatter from dbt_semantic_interfaces.protocols.protocol_hint import ProtocolHint +from dbt_semantic_interfaces.protocols.query_interface import QueryInterfaceEntity, QueryInterfaceEntityFactory from dbt_semantic_interfaces.references import EntityReference from typing_extensions import override from metricflow.errors.errors import InvalidQuerySyntax -from metricflow.protocols.query_interface import QueryInterfaceEntity, QueryInterfaceEntityFactory from metricflow.specs.column_assoc import ColumnAssociationResolver from metricflow.specs.specs import EntitySpec diff --git a/metricflow/specs/where_filter_time_dimension.py b/metricflow/specs/where_filter_time_dimension.py index 7537d4b3f4..75d12d5fbe 100644 --- a/metricflow/specs/where_filter_time_dimension.py +++ b/metricflow/specs/where_filter_time_dimension.py @@ -4,11 +4,14 @@ from dbt_semantic_interfaces.call_parameter_sets import FilterCallParameterSets from dbt_semantic_interfaces.protocols.protocol_hint import ProtocolHint +from dbt_semantic_interfaces.protocols.query_interface import ( + QueryInterfaceTimeDimension, + QueryInterfaceTimeDimensionFactory, +) from dbt_semantic_interfaces.type_enums import TimeGranularity from typing_extensions import override from metricflow.errors.errors import InvalidQuerySyntax -from metricflow.protocols.query_interface import QueryInterfaceTimeDimension, QueryInterfaceTimeDimensionFactory from metricflow.specs.column_assoc import ColumnAssociationResolver from metricflow.specs.dimension_spec_resolver import DimensionSpecResolver from metricflow.specs.specs import TimeDimensionSpec