From aa3d8b57562af00acdae3ad6af26a3fe9102b4ce Mon Sep 17 00:00:00 2001 From: William Deng <33618746+WilliamDee@users.noreply.github.com> Date: Tue, 12 Nov 2024 18:47:27 -0500 Subject: [PATCH] Remove unnecessary check against legacy field (#368) ### Description We decided that `Metric.type_params.grain_to_date` will not be changed to support custom grain, but this validation makes it break since it expects it to be the same typing. ### Checklist - [x] I have read [the contributing guide](https://github.com/dbt-labs/dbt-semantic-interfaces/blob/main/CONTRIBUTING.md) and understand what's expected of me - [x] I have signed the [CLA](https://docs.getdbt.com/docs/contributor-license-agreements) - [x] This PR includes tests, or tests are not required/relevant for this PR - [x] I have run `changie new` to [create a changelog entry](https://github.com/dbt-labs/dbt-semantic-interfaces/blob/main/CONTRIBUTING.md#adding-a-changelog-entry) --- dbt_semantic_interfaces/validations/metrics.py | 3 ++- pyproject.toml | 2 +- tests/validations/test_metrics.py | 15 +-------------- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/dbt_semantic_interfaces/validations/metrics.py b/dbt_semantic_interfaces/validations/metrics.py index 83c9b0ee..aef07ed2 100644 --- a/dbt_semantic_interfaces/validations/metrics.py +++ b/dbt_semantic_interfaces/validations/metrics.py @@ -76,7 +76,8 @@ def validate_manifest(semantic_manifest: SemanticManifestT) -> Sequence[Validati else None ) if ( - type_params_field_value + field == "window" + and type_params_field_value and cumulative_type_params_field_value and cumulative_type_params_field_value != type_params_field_value ): diff --git a/pyproject.toml b/pyproject.toml index cfdd39b3..96439504 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "dbt-semantic-interfaces" -version = "0.8.0" +version = "0.8.1" description = 'The shared semantic layer definitions that dbt-core and MetricFlow use' readme = "README.md" requires-python = ">=3.8" diff --git a/tests/validations/test_metrics.py b/tests/validations/test_metrics.py index 3e02ce65..8571373b 100644 --- a/tests/validations/test_metrics.py +++ b/tests/validations/test_metrics.py @@ -614,18 +614,6 @@ def test_cumulative_metrics() -> None: # noqa: D ), ), ), - # Metrics with duplicated window or grain_to_date - should get warning - metric_with_guaranteed_meta( - name="what_a_metric", - type=MetricType.CUMULATIVE, - type_params=PydanticMetricTypeParams( - measure=PydanticMetricInputMeasure(name=measure_name), - grain_to_date=TimeGranularity.YEAR, - cumulative_type_params=PydanticCumulativeTypeParams( - grain_to_date=TimeGranularity.HOUR.value, - ), - ), - ), metric_with_guaranteed_meta( name="dis_bad", type=MetricType.CUMULATIVE, @@ -688,12 +676,11 @@ def test_cumulative_metrics() -> None: # noqa: D ) build_issues = validation_results.all_issues - assert len(build_issues) == 4 + assert len(build_issues) == 3 expected_substrings = [ "Invalid time granularity", "Both window and grain_to_date set for cumulative metric. Please set one or the other.", "Got differing values for `window`", - "Got differing values for `grain_to_date`", ] check_error_in_issues(error_substrings=expected_substrings, issues=build_issues)