From 4b94b5b5eb1fc912e7bf7932e19246f722c75315 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Mon, 6 Nov 2023 08:59:46 -0800 Subject: [PATCH] Changes as required by `dbt-semantic-interfaces~=0.4.0`. --- metricflow/query/query_parser.py | 9 +++++---- .../simple_manifest/saved_queries.yaml | 17 +++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/metricflow/query/query_parser.py b/metricflow/query/query_parser.py index cad5e9f0e1..f302a48365 100644 --- a/metricflow/query/query_parser.py +++ b/metricflow/query/query_parser.py @@ -199,15 +199,16 @@ def parse_and_validate_saved_query( # Merge interface could streamline this. where_filters: List[WhereFilter] = [] - if saved_query.where is not None: - where_filters.extend(saved_query.where.where_filters) + if saved_query.query_params.where is not None: + where_filters.extend(saved_query.query_params.where.where_filters) if where_filter is not None: where_filters.append(where_filter) return self.parse_and_validate_query( - metrics=tuple(MetricParameter(name=metric_name) for metric_name in saved_query.metrics), + metrics=tuple(MetricParameter(name=metric_name) for metric_name in saved_query.query_params.metrics), group_by=tuple( - parse_object_builder_naming_scheme(group_by_item_name) for group_by_item_name in saved_query.group_bys + parse_object_builder_naming_scheme(group_by_item_name) + for group_by_item_name in saved_query.query_params.group_by ), where_constraint=merge_to_single_where_filter(PydanticWhereFilterIntersection(where_filters=where_filters)), limit=limit, diff --git a/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/saved_queries.yaml b/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/saved_queries.yaml index 0149eacd23..f8c33f1b89 100644 --- a/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/saved_queries.yaml +++ b/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/saved_queries.yaml @@ -2,11 +2,12 @@ saved_query: name: p0_booking description: Booking-related metrics that are of the highest priority. - metrics: - - bookings - - instant_bookings - group_bys: - - TimeDimension('metric_time', 'day') - - Dimension('listing__capacity_latest') - where: - - "{{ Dimension('listing__capacity_latest') }} > 3" + query_params: + metrics: + - bookings + - instant_bookings + group_by: + - TimeDimension('metric_time', 'day') + - Dimension('listing__capacity_latest') + where: + - "{{ Dimension('listing__capacity_latest') }} > 3"