Skip to content

Commit

Permalink
Allow metrics in semantic layer filters (#9773)
Browse files Browse the repository at this point in the history
* Tests for metrics in filters

* Bump DSI version

* Update test

* Changelog
  • Loading branch information
courtneyholcomb authored Mar 22, 2024
1 parent b435e26 commit 8c8c628
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20240322-103124.yaml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions tests/functional/metrics/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
Expand Down
1 change: 1 addition & 0 deletions tests/functional/saved_queries/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/saved_queries/test_saved_query_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8c8c628

Please sign in to comment.