Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Jun 6, 2024
1 parent e61836c commit c64eb7c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand All @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down

0 comments on commit c64eb7c

Please sign in to comment.