From 0c1d3ab088ee20d010f149ed38a67e64e494357e Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Mon, 8 Jul 2024 17:00:17 -0700 Subject: [PATCH] WIP --- .changes/unreleased/Features-20240628-074617.yaml | 2 +- .../query/group_by_item/group_by_item_resolver.py | 10 +++++++++- .../simple_manifest/metrics.yaml | 6 ++++++ .../semantic_models/listings_latest.yaml | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.changes/unreleased/Features-20240628-074617.yaml b/.changes/unreleased/Features-20240628-074617.yaml index 2ad17eaf7d..daecb746f9 100644 --- a/.changes/unreleased/Features-20240628-074617.yaml +++ b/.changes/unreleased/Features-20240628-074617.yaml @@ -1,5 +1,5 @@ kind: Features -body: Use default_grain to resolve metric_time. +body: Use default_granularity to resolve metric_time. time: 2024-06-28T07:46:17.768805-07:00 custom: Author: courtneyholcomb diff --git a/metricflow-semantics/metricflow_semantics/query/group_by_item/group_by_item_resolver.py b/metricflow-semantics/metricflow_semantics/query/group_by_item/group_by_item_resolver.py index 542cbd67b6..beeb358727 100644 --- a/metricflow-semantics/metricflow_semantics/query/group_by_item/group_by_item_resolver.py +++ b/metricflow-semantics/metricflow_semantics/query/group_by_item/group_by_item_resolver.py @@ -104,8 +104,16 @@ def resolve_matching_item_for_querying( issue_set=push_down_result.issue_set, ) + # TODO: this isn't working, figure out why + filter_to_use = ( + DefaultTimeGranularityPattern( + metric_lookup=self._manifest_lookup.metric_lookup, queried_metrics=queried_metrics + ) + if queried_metrics + else + ) push_down_result = push_down_result.filter_candidates_by_pattern( - BaseTimeGrainPattern(), + filter_to_use, ) logger.info( f"Spec pattern:\n" 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 877453249f..0923e2b4af 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 @@ -92,6 +92,7 @@ metric: type: simple type_params: measure: listings + default_granularity: day --- metric: name: "lux_listings" @@ -100,6 +101,7 @@ metric: type_params: measure: listings filter: "{{ Dimension('listing__is_lux_latest') }}" + default_granularity: day --- metric: name: "smallest_listing" @@ -107,6 +109,7 @@ metric: type: simple type_params: measure: smallest_listing + default_granularity: day --- metric: name: "largest_listing" @@ -114,6 +117,7 @@ metric: type: simple type_params: measure: largest_listing + default_granularity: day --- metric: name: "identity_verifications" @@ -769,6 +773,7 @@ metric: type_params: measure: listings filter: "{{ Metric('bookings', ['listing']) }} > 2" + default_granularity: day --- metric: name: popular_listing_bookings_per_booker @@ -780,3 +785,4 @@ metric: denominator: name: listings filter: "{{ Metric('views', ['listing']) }} > 10" + default_granularity: day diff --git a/metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_manifest/semantic_models/listings_latest.yaml b/metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_manifest/semantic_models/listings_latest.yaml index c14800050e..7de7c8bf30 100644 --- a/metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_manifest/semantic_models/listings_latest.yaml +++ b/metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_manifest/semantic_models/listings_latest.yaml @@ -26,7 +26,7 @@ semantic_model: type: time expr: created_at type_params: - time_granularity: day + time_granularity: second - name: created_at type: time type_params: