diff --git a/metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_manifest/metrics.yaml b/metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_manifest/metrics.yaml index fe28fb047..7e34bebef 100644 --- a/metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_manifest/metrics.yaml +++ b/metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_manifest/metrics.yaml @@ -719,6 +719,16 @@ metric: - name: bookings_offset_once offset_window: 2 days --- +metric: + name: "bookings_offset_martian_day" + description: bookings metric offset by a martian day. + type: derived + type_params: + expr: 2 * bookings + metrics: + - name: bookings + offset_window: 1 martian_day +--- metric: name: bookings_at_start_of_month description: | diff --git a/metricflow-semantics/tests_metricflow_semantics/model/semantics/test_metric_lookup.py b/metricflow-semantics/tests_metricflow_semantics/model/semantics/test_metric_lookup.py index 8706073d2..d9942eeb4 100644 --- a/metricflow-semantics/tests_metricflow_semantics/model/semantics/test_metric_lookup.py +++ b/metricflow-semantics/tests_metricflow_semantics/model/semantics/test_metric_lookup.py @@ -2,6 +2,7 @@ import logging +from dbt_semantic_interfaces.implementations.metric import PydanticMetricTimeWindow from dbt_semantic_interfaces.references import MetricReference from dbt_semantic_interfaces.type_enums import TimeGranularity from metricflow_semantics.model.semantic_manifest_lookup import SemanticManifestLookup @@ -21,3 +22,18 @@ def test_min_queryable_time_granularity_for_different_agg_time_grains( # noqa: # Since `monthly_bookings_to_daily_bookings` is based on metrics with DAY and MONTH aggregation time grains, # the minimum queryable grain should be MONTH. assert min_queryable_grain == TimeGranularity.MONTH + + +def test_custom_offset_window_for_metric( + simple_semantic_manifest_lookup: SemanticManifestLookup, +) -> None: + """Test offset window with custom grain supplied. + + TODO: As of now, the functionality of an offset window with a custom grain is not supported in MF. + This test is added to show that at least the parsing is successful using a custom grain offset window. + Once support for that is added in MF + relevant tests, this test can be removed. + """ + metric = simple_semantic_manifest_lookup.metric_lookup.get_metric(MetricReference("bookings_offset_martian_day")) + + assert len(metric.input_metrics) == 1 + assert metric.input_metrics[0].offset_window == PydanticMetricTimeWindow(count=1, granularity="martian_day")