From 39eca851e5eb638928f7943a6cc6e8e17309b98d Mon Sep 17 00:00:00 2001 From: Quigley Malcolm Date: Wed, 14 Jun 2023 14:53:43 -0700 Subject: [PATCH 1/3] Update semantic model parsing test to check measure agg params --- .../semantic_models/test_semantic_model_parsing.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/functional/semantic_models/test_semantic_model_parsing.py b/tests/functional/semantic_models/test_semantic_model_parsing.py index 295b5d7949a..149b609b75f 100644 --- a/tests/functional/semantic_models/test_semantic_model_parsing.py +++ b/tests/functional/semantic_models/test_semantic_model_parsing.py @@ -29,6 +29,18 @@ - name: has_revenue expr: true agg: sum_boolean + - name: discrete_order_value_p99 + expr: order_total + agg: percentile + agg_params: + percentile: 0.99 + use_discrete_percentile: True + use_approximate_percentile: False + - name: test_agg_params_optional_are_empty + expr: order_total + agg: percentile + agg_params: + percentile: 0.99 dimensions: - name: ds @@ -71,7 +83,7 @@ def test_semantic_model_parsing(self, project): semantic_model.node_relation.relation_name == f'"dbt"."{project.test_schema}"."fct_revenue"' ) - assert len(semantic_model.measures) == 3 + assert len(semantic_model.measures) == 5 @pytest.mark.skip("Restore this test when partial parsing is implemented.") def test_semantic_model_partial_parsing(self, project): From 330877b0f7870838fc2718cb02b3acd333661369 Mon Sep 17 00:00:00 2001 From: Quigley Malcolm Date: Wed, 14 Jun 2023 14:54:10 -0700 Subject: [PATCH 2/3] Make `use_discrete_percentile` and `use_approximate_percentile` non optional and default false This was a mistake in our implementation of the MeasureAggregationParams. We had defined them as optional and defaulting to `None`. However, as the protocol states, they cannot be `None`, they must be a boolean value. Thus now we now ensure them. --- core/dbt/contracts/graph/semantic_models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/dbt/contracts/graph/semantic_models.py b/core/dbt/contracts/graph/semantic_models.py index 8645a1e54b0..492c3188808 100644 --- a/core/dbt/contracts/graph/semantic_models.py +++ b/core/dbt/contracts/graph/semantic_models.py @@ -120,8 +120,8 @@ def is_linkable_entity_type(self) -> bool: @dataclass class MeasureAggregationParameters(dbtClassMixin): percentile: Optional[float] = None - use_discrete_percentile: Optional[bool] = None - use_approximate_percentile: Optional[bool] = None + use_discrete_percentile: bool = False + use_approximate_percentile: bool = False @dataclass From 2bfea8179981fea491343904427ae2eac88c80e7 Mon Sep 17 00:00:00 2001 From: Quigley Malcolm Date: Wed, 14 Jun 2023 15:00:15 -0700 Subject: [PATCH 3/3] Add changie doc for measure percentile fixes --- .changes/unreleased/Fixes-20230614-145954.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changes/unreleased/Fixes-20230614-145954.yaml diff --git a/.changes/unreleased/Fixes-20230614-145954.yaml b/.changes/unreleased/Fixes-20230614-145954.yaml new file mode 100644 index 00000000000..febe290ffd8 --- /dev/null +++ b/.changes/unreleased/Fixes-20230614-145954.yaml @@ -0,0 +1,7 @@ +kind: Fixes +body: Update `use_discrete_percentile` and `use_approximate_percentile` to be non + optional and default to `False` +time: 2023-06-14T14:59:54.042341-07:00 +custom: + Author: QMalcolm + Issue: "7866"