Skip to content

Commit

Permalink
fixed all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DevonFulcher committed Oct 4, 2023
1 parent d37ec16 commit 3c97f45
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
23 changes: 5 additions & 18 deletions metricflow/specs/dimension_spec_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,9 @@ def resolve_dimension_spec(self, name: str, entity_path: Sequence[str]) -> Dimen
tuple(EntityReference(element_name=arg) for arg in entity_path) + structured_name.entity_links
),
)
assert call_parameter_set in self._call_parameter_sets.dimension_call_parameter_sets
return self._convert_to_dimension_spec(call_parameter_set)

def _convert_to_dimension_spec(
self,
parameter_set: DimensionCallParameterSet,
) -> DimensionSpec: # noqa: D
return DimensionSpec(
element_name=parameter_set.dimension_reference.element_name,
entity_links=parameter_set.entity_path,
element_name=call_parameter_set.dimension_reference.element_name,
entity_links=call_parameter_set.entity_path,
)

def resolve_time_dimension_spec(
Expand All @@ -54,14 +47,8 @@ def resolve_time_dimension_spec(
),
)
assert call_parameter_set in self._call_parameter_sets.time_dimension_call_parameter_sets
return self._convert_to_time_dimension_spec(call_parameter_set)

def _convert_to_time_dimension_spec(
self,
parameter_set: TimeDimensionCallParameterSet,
) -> TimeDimensionSpec: # noqa: D
return TimeDimensionSpec(
element_name=parameter_set.time_dimension_reference.element_name,
entity_links=parameter_set.entity_path,
time_granularity=parameter_set.time_granularity,
element_name=call_parameter_set.time_dimension_reference.element_name,
entity_links=call_parameter_set.entity_path,
time_granularity=call_parameter_set.time_granularity,
)
2 changes: 1 addition & 1 deletion metricflow/specs/where_filter_time_dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from dbt_semantic_interfaces.protocols.protocol_hint import ProtocolHint
from dbt_semantic_interfaces.type_enums import TimeGranularity
from typing_extensions import override
from metricflow.errors.errors import InvalidQuerySyntax

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
Expand Down
4 changes: 2 additions & 2 deletions metricflow/test/model/test_where_filter_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def test_dimension_in_filter_with_grain( # noqa: D
column_association_resolver: ColumnAssociationResolver,
) -> None:
where_filter = PydanticWhereFilter(
where_sql_template="{{ Dimension('listing__country_latest').grain('WEEKLY') }} = 'US'"
where_sql_template="{{ Dimension('listing__country_latest').grain('WEEK') }} = 'US'"
)

where_filter_spec = WhereSpecFactory(
column_association_resolver=column_association_resolver,
).create_from_where_filter(where_filter)

assert where_filter_spec.where_sql == "listing__country_latest = 'US'"
assert where_filter_spec.where_sql == "listing__country_latest__week = 'US'"
assert where_filter_spec.linkable_spec_set == LinkableSpecSet(
dimension_specs=(),
time_dimension_specs=(
Expand Down

0 comments on commit 3c97f45

Please sign in to comment.