From c64eb7c088e5fdfe73b5b88b291f271142015417 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Thu, 6 Jun 2024 15:29:07 -0700 Subject: [PATCH] WIP --- .../specs/where_filter_dimension.py | 4 ---- .../specs/where_filter_entity.py | 22 ++++--------------- .../specs/where_filter_metric.py | 1 - .../time/dateutil_adjuster.py | 13 +++++------ 4 files changed, 10 insertions(+), 30 deletions(-) diff --git a/metricflow-semantics/metricflow_semantics/specs/where_filter_dimension.py b/metricflow-semantics/metricflow_semantics/specs/where_filter_dimension.py index 77c6faa5cc..d95a1f4bf3 100644 --- a/metricflow-semantics/metricflow_semantics/specs/where_filter_dimension.py +++ b/metricflow-semantics/metricflow_semantics/specs/where_filter_dimension.py @@ -83,10 +83,6 @@ def date_part(self, date_part_name: str) -> QueryInterfaceDimension: date_part=DatePart(date_part_name.lower()), ) - def descending(self, _is_descending: bool) -> QueryInterfaceDimension: - """Set the sort order for order-by.""" - raise InvalidQuerySyntax("descending is invalid in the where parameter") - def __str__(self) -> str: """Returns the column name. diff --git a/metricflow-semantics/metricflow_semantics/specs/where_filter_entity.py b/metricflow-semantics/metricflow_semantics/specs/where_filter_entity.py index 080beabfcd..8cc56523ea 100644 --- a/metricflow-semantics/metricflow_semantics/specs/where_filter_entity.py +++ b/metricflow-semantics/metricflow_semantics/specs/where_filter_entity.py @@ -23,13 +23,9 @@ from metricflow_semantics.specs.rendered_spec_tracker import RenderedSpecTracker -class WhereFilterEntity(ProtocolHint[QueryInterfaceEntity]): +class RenderedWhereFilterEntity: """An entity that is passed in through the where filter parameter.""" - @override - def _implements_protocol(self) -> QueryInterfaceEntity: - return self - def __init__( # noqa self, column_association_resolver: ColumnAssociationResolver, @@ -50,12 +46,6 @@ def __init__( # noqa self._time_grain = time_grain self._date_part = date_part - def descending(self, _is_descending: bool) -> QueryInterfaceEntity: - """Set the sort order for order-by.""" - raise InvalidQuerySyntax( - "Can't set descending in the where clause. Try setting descending in the order_by clause instead" - ) - def __str__(self) -> str: """Returns the column name. @@ -79,16 +69,12 @@ def __str__(self) -> str: return column_association.column_name -class WhereFilterEntityFactory(ProtocolHint[QueryInterfaceEntityFactory]): - """Creates a WhereFilterEntity. +class RenderedWhereFilterEntityFactory(ProtocolHint[QueryInterfaceEntityFactory]): + """Creates a RenderedWhereFilterEntity. Each call to `create` adds an EntitySpec to entity_specs. """ - @override - def _implements_protocol(self) -> QueryInterfaceEntityFactory: - return self - def __init__( # noqa self, column_association_resolver: ColumnAssociationResolver, @@ -105,7 +91,7 @@ def create(self, entity_name: str, entity_path: Sequence[str] = ()) -> WhereFilt """Create a WhereFilterEntity.""" structured_name = DunderedNameFormatter.parse_name(entity_name.lower()) - return WhereFilterEntity( + return RenderedWhereFilterEntity( column_association_resolver=self._column_association_resolver, resolved_spec_lookup=self._resolved_spec_lookup, where_filter_location=self._where_filter_location, diff --git a/metricflow-semantics/metricflow_semantics/specs/where_filter_metric.py b/metricflow-semantics/metricflow_semantics/specs/where_filter_metric.py index 9fe8af21f8..2c81332490 100644 --- a/metricflow-semantics/metricflow_semantics/specs/where_filter_metric.py +++ b/metricflow-semantics/metricflow_semantics/specs/where_filter_metric.py @@ -18,7 +18,6 @@ ) from metricflow_semantics.specs.column_assoc import ColumnAssociationResolver from metricflow_semantics.specs.rendered_spec_tracker import RenderedSpecTracker - from metricflow_semantics.specs.where_filter_entity import WhereFilterEntity diff --git a/metricflow-semantics/metricflow_semantics/time/dateutil_adjuster.py b/metricflow-semantics/metricflow_semantics/time/dateutil_adjuster.py index cf553ce49e..9c601d8c4e 100644 --- a/metricflow-semantics/metricflow_semantics/time/dateutil_adjuster.py +++ b/metricflow-semantics/metricflow_semantics/time/dateutil_adjuster.py @@ -5,7 +5,6 @@ import dateutil.relativedelta from dateutil.relativedelta import relativedelta -from dbt_semantic_interfaces.enum_extension import assert_values_exhausted from dbt_semantic_interfaces.type_enums import TimeGranularity from typing_extensions import override @@ -32,8 +31,8 @@ def _relative_delta_for_window(self, time_granularity: TimeGranularity, count: i return relativedelta(months=count * 3) elif time_granularity is TimeGranularity.YEAR: return relativedelta(years=count) - else: - assert_values_exhausted(time_granularity) + # else: + # assert_values_exhausted(time_granularity) @override def expand_time_constraint_to_fill_granularity( @@ -70,8 +69,8 @@ def adjust_to_start_of_period( return date_to_adjust + relativedelta(month=10, day=1) elif time_granularity is TimeGranularity.YEAR: return date_to_adjust + relativedelta(month=1, day=1) - else: - assert_values_exhausted(time_granularity) + # else: + # assert_values_exhausted(time_granularity) @override def adjust_to_end_of_period( @@ -94,8 +93,8 @@ def adjust_to_end_of_period( return date_to_adjust + relativedelta(month=12, day=31) elif time_granularity is TimeGranularity.YEAR: return date_to_adjust + relativedelta(month=12, day=31) - else: - assert_values_exhausted(time_granularity) + # else: + # assert_values_exhausted(time_granularity) @override def expand_time_constraint_for_cumulative_metric(