From 72d67928b30e9759bd1c5fe757546c844778b7bc Mon Sep 17 00:00:00 2001 From: Devon Fulcher Date: Mon, 27 Nov 2023 13:37:47 -0600 Subject: [PATCH] test to ensure Dimension and TimeDimension syntax are identical in the case of a time dimension --- .../Under the Hood-20231127-133132.yaml | 7 +++++++ metricflow/test/model/test_where_filter_spec.py | 15 +++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 .changes/unreleased/Under the Hood-20231127-133132.yaml diff --git a/.changes/unreleased/Under the Hood-20231127-133132.yaml b/.changes/unreleased/Under the Hood-20231127-133132.yaml new file mode 100644 index 0000000000..3631d96e8f --- /dev/null +++ b/.changes/unreleased/Under the Hood-20231127-133132.yaml @@ -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 diff --git a/metricflow/test/model/test_where_filter_spec.py b/metricflow/test/model/test_where_filter_spec.py index 3d6e905259..305052d77e 100644 --- a/metricflow/test/model/test_where_filter_spec.py +++ b/metricflow/test/model/test_where_filter_spec.py @@ -15,6 +15,7 @@ EntitySpec, LinkableSpecSet, TimeDimensionSpec, + WhereFilterSpec, ) from metricflow.specs.where_filter_transform import WhereSpecFactory @@ -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