Skip to content

Commit

Permalink
test to ensure Dimension and TimeDimension syntax are identical in th…
Browse files Browse the repository at this point in the history
…e case of a time dimension
  • Loading branch information
DevonFulcher committed Nov 27, 2023
1 parent cef3330 commit 72d6792
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changes/unreleased/Under the Hood-20231127-133132.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Under the Hood
body: Test to ensure Dimension and TimeDimension syntax are identical in the case
of time dimensions
time: 2023-11-27T13:31:32.631027-06:00
custom:
Author: DevonFulcher
Issue: None
15 changes: 15 additions & 0 deletions metricflow/test/model/test_where_filter_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
EntitySpec,
LinkableSpecSet,
TimeDimensionSpec,
WhereFilterSpec,
)
from metricflow.specs.where_filter_transform import WhereSpecFactory

Expand Down Expand Up @@ -204,3 +205,17 @@ def test_entity_in_filter( # noqa: D
time_dimension_specs=(),
entity_specs=(EntitySpec(element_name="user", entity_links=(EntityReference(element_name="listing"),)),),
)


def test_dimension_time_dimension_parity(column_association_resolver: ColumnAssociationResolver) -> None: # noqa
def get_spec(dimension: str) -> WhereFilterSpec:
where_filter = PydanticWhereFilter(where_sql_template="{{" + dimension + "}} = '2020'")

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

time_dimension_spec = get_spec("TimeDimension('metric_time', 'week', date_part_name='day')")
dimension_spec = get_spec("Dimension('metric_time').date_part('day').grain('week')")

assert time_dimension_spec == dimension_spec

0 comments on commit 72d6792

Please sign in to comment.