From 031f03d5bf9f5bd060eb600f5cd5da5f3163d09c Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Wed, 8 Oct 2025 08:46:25 -0700 Subject: [PATCH 1/2] /* PR_START p/measure_migration 14 */ Add test for agg time dimension specs --- .../model/test_semantic_model_container.py | 28 +++----- ...gregation_time_dimension_specs__result.txt | 71 +++++++++++++++++++ 2 files changed, 81 insertions(+), 18 deletions(-) create mode 100644 metricflow-semantics/tests_metricflow_semantics/snapshots/test_semantic_model_container.py/dict/test_get_aggregation_time_dimension_specs__result.txt diff --git a/metricflow-semantics/tests_metricflow_semantics/model/test_semantic_model_container.py b/metricflow-semantics/tests_metricflow_semantics/model/test_semantic_model_container.py index 3659c5e91f..63bbf42683 100644 --- a/metricflow-semantics/tests_metricflow_semantics/model/test_semantic_model_container.py +++ b/metricflow-semantics/tests_metricflow_semantics/model/test_semantic_model_container.py @@ -71,23 +71,15 @@ def test_get_semantic_models_for_entity(semantic_model_lookup: SemanticModelLook assert len(linked_semantic_models) == 10 -def test_get_valid_agg_time_dimensions_for_metric( # noqa: D103 - metric_lookup: MetricLookup, semantic_model_lookup: SemanticModelLookup +def test_get_aggregation_time_dimension_specs( # noqa: D103 + request: FixtureRequest, + mf_test_configuration: MetricFlowTestConfiguration, + metric_lookup: MetricLookup, + semantic_model_lookup: SemanticModelLookup, ) -> None: + result = {} for metric_name in ["views", "listings", "bookings_per_view"]: - metric_reference = MetricReference(metric_name) - metric = metric_lookup.get_metric(metric_reference) - metric_agg_time_dims = metric_lookup.get_valid_agg_time_dimensions_for_metric(metric_reference) - measure_agg_time_dims = list( - { - semantic_model_lookup.measure_lookup.get_properties( - measure.measure_reference - ).agg_time_dimension_reference - for measure in metric.input_measures - } - ) - if len(measure_agg_time_dims) == 1: - for metric_agg_time_dim in metric_agg_time_dims: - assert metric_agg_time_dim.reference == measure_agg_time_dims[0] - else: - assert len(metric_agg_time_dims) == 0 + specs = metric_lookup.get_aggregation_time_dimension_specs(MetricReference(metric_name)) + result[metric_name] = list(spec.qualified_name for spec in specs) + + assert_object_snapshot_equal(request=request, snapshot_configuration=mf_test_configuration, obj=result) diff --git a/metricflow-semantics/tests_metricflow_semantics/snapshots/test_semantic_model_container.py/dict/test_get_aggregation_time_dimension_specs__result.txt b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_semantic_model_container.py/dict/test_get_aggregation_time_dimension_specs__result.txt new file mode 100644 index 0000000000..68e121b16b --- /dev/null +++ b/metricflow-semantics/tests_metricflow_semantics/snapshots/test_semantic_model_container.py/dict/test_get_aggregation_time_dimension_specs__result.txt @@ -0,0 +1,71 @@ +test_name: test_get_aggregation_time_dimension_specs +test_filename: test_semantic_model_container.py +--- +{ + 'views': [ + 'view__ds__day', + 'view__ds__week', + 'view__ds__month', + 'view__ds__quarter', + 'view__ds__year', + 'view__ds__extract_year', + 'view__ds__extract_quarter', + 'view__ds__extract_month', + 'view__ds__extract_day', + 'view__ds__extract_dow', + 'view__ds__extract_doy', + 'view__ds__alien_day', + 'metric_time__day', + 'metric_time__week', + 'metric_time__month', + 'metric_time__quarter', + 'metric_time__year', + 'metric_time__extract_year', + 'metric_time__extract_quarter', + 'metric_time__extract_month', + 'metric_time__extract_day', + 'metric_time__extract_dow', + 'metric_time__extract_doy', + 'metric_time__alien_day', + ], + 'listings': [ + 'listing__ds__day', + 'listing__ds__week', + 'listing__ds__month', + 'listing__ds__quarter', + 'listing__ds__year', + 'listing__ds__extract_year', + 'listing__ds__extract_quarter', + 'listing__ds__extract_month', + 'listing__ds__extract_day', + 'listing__ds__extract_dow', + 'listing__ds__extract_doy', + 'listing__ds__alien_day', + 'metric_time__day', + 'metric_time__week', + 'metric_time__month', + 'metric_time__quarter', + 'metric_time__year', + 'metric_time__extract_year', + 'metric_time__extract_quarter', + 'metric_time__extract_month', + 'metric_time__extract_day', + 'metric_time__extract_dow', + 'metric_time__extract_doy', + 'metric_time__alien_day', + ], + 'bookings_per_view': [ + 'metric_time__day', + 'metric_time__week', + 'metric_time__month', + 'metric_time__quarter', + 'metric_time__year', + 'metric_time__extract_year', + 'metric_time__extract_quarter', + 'metric_time__extract_month', + 'metric_time__extract_day', + 'metric_time__extract_dow', + 'metric_time__extract_doy', + 'metric_time__alien_day', + ], +} From 0113333503c08832dcc682d6edd815cd72f96ccf Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Wed, 8 Oct 2025 15:00:31 -0700 Subject: [PATCH 2/2] Add changelog entry --- .changes/unreleased/Under the Hood-20251008-150031.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Under the Hood-20251008-150031.yaml diff --git a/.changes/unreleased/Under the Hood-20251008-150031.yaml b/.changes/unreleased/Under the Hood-20251008-150031.yaml new file mode 100644 index 0000000000..d59dcc0c7d --- /dev/null +++ b/.changes/unreleased/Under the Hood-20251008-150031.yaml @@ -0,0 +1,6 @@ +kind: Under the Hood +body: Add a test for `MetricLookup. get_aggregation_time_dimension_specs()` +time: 2025-10-08T15:00:31.500705-07:00 +custom: + Author: plypaul + Issue: "1890"