From 67fd463c6f1ccd88a356f801ea8d498a4bb9e4e9 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Mon, 18 Mar 2024 15:07:56 -0700 Subject: [PATCH 1/4] Tests for metrics in filters --- tests/functional/metrics/fixtures.py | 8 ++++++++ tests/functional/saved_queries/fixtures.py | 1 + 2 files changed, 9 insertions(+) diff --git a/tests/functional/metrics/fixtures.py b/tests/functional/metrics/fixtures.py index 95cc5caa0e5..c9d2d0ab190 100644 --- a/tests/functional/metrics/fixtures.py +++ b/tests/functional/metrics/fixtures.py @@ -88,6 +88,14 @@ metrics: - average_tenure expr: "average_tenure + 1" + + - name: tenured_people + label: Tenured People + description: People who have been here more than 1 year + type: simple + type_params: + measure: people + filter: "{{ Metric('collective_tenure', ['id']) }} > 2" """ metricflow_time_spine_sql = """ diff --git a/tests/functional/saved_queries/fixtures.py b/tests/functional/saved_queries/fixtures.py index fd1f6168a4b..b2025ba208a 100644 --- a/tests/functional/saved_queries/fixtures.py +++ b/tests/functional/saved_queries/fixtures.py @@ -17,6 +17,7 @@ where: - "{{ Dimension('user__ds', 'DAY') }} <= now()" - "{{ Dimension('user__ds', 'DAY') }} >= '2023-01-01'" + - "{{ Metric('txn_revenue', ['id']) }} > 1" exports: - name: my_export config: From 89e109d66e592e3da96a447b40f2ae264a3bb09e Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Tue, 19 Mar 2024 16:21:12 -0700 Subject: [PATCH 2/4] Bump DSI version --- core/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/setup.py b/core/setup.py index e49ad973568..eef7dae7fe4 100644 --- a/core/setup.py +++ b/core/setup.py @@ -73,7 +73,7 @@ # Accept patches but avoid automatically updating past a set minor version range. "dbt-extractor>=0.5.0,<=0.6", "minimal-snowplow-tracker>=0.0.2,<0.1", - "dbt-semantic-interfaces>=0.5.0,<0.6", + "dbt-semantic-interfaces>=0.5.1,<0.6", # Minor versions for these are expected to be backwards-compatible "dbt-common<2.0", "dbt-adapters>=0.1.0a2,<2.0", From 8ebe71edccb9461fcb415afdae13888e00a48f13 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Thu, 21 Mar 2024 15:21:00 -0700 Subject: [PATCH 3/4] Update test --- tests/functional/saved_queries/test_saved_query_parsing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/saved_queries/test_saved_query_parsing.py b/tests/functional/saved_queries/test_saved_query_parsing.py index f6343637160..9c02b7c5418 100644 --- a/tests/functional/saved_queries/test_saved_query_parsing.py +++ b/tests/functional/saved_queries/test_saved_query_parsing.py @@ -41,7 +41,7 @@ def test_semantic_model_parsing(self, project): assert saved_query.name == "test_saved_query" assert len(saved_query.query_params.metrics) == 1 assert len(saved_query.query_params.group_by) == 1 - assert len(saved_query.query_params.where.where_filters) == 2 + assert len(saved_query.query_params.where.where_filters) == 3 assert len(saved_query.depends_on.nodes) == 1 assert saved_query.description == "My SavedQuery Description" assert len(saved_query.exports) == 1 From 7a99fe1f3372dd83c68ee0bdb0feba9f83196f5f Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Fri, 22 Mar 2024 10:31:34 -0700 Subject: [PATCH 4/4] Changelog --- .changes/unreleased/Features-20240322-103124.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Features-20240322-103124.yaml diff --git a/.changes/unreleased/Features-20240322-103124.yaml b/.changes/unreleased/Features-20240322-103124.yaml new file mode 100644 index 00000000000..735dd44bdbc --- /dev/null +++ b/.changes/unreleased/Features-20240322-103124.yaml @@ -0,0 +1,6 @@ +kind: Features +body: Allow metrics in semantic layer filters. +time: 2024-03-22T10:31:24.76978-07:00 +custom: + Author: courtneyholcomb + Issue: "9804"