Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix where filter object inheritance #771

Merged
merged 3 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20230912-161509.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: A simple update to make the where filter query parameter objects more accurate
time: 2023-09-12T16:15:09.057779-05:00
custom:
Author: DevonFulcher
Issue: None
14 changes: 3 additions & 11 deletions metricflow/specs/where_filter_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
14 changes: 3 additions & 11 deletions metricflow/specs/where_filter_time_dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down