From eea8492526e519909466ad99cc107960f0581cb0 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Wed, 8 Nov 2023 10:48:22 -0800 Subject: [PATCH] Write integration tests --- .../test/integration/configured_test_case.py | 1 + .../test_cases/itest_dimensions.yaml | 58 ++++++++++++++++++- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/metricflow/test/integration/configured_test_case.py b/metricflow/test/integration/configured_test_case.py index b0e59d3ab2..b01e163619 100644 --- a/metricflow/test/integration/configured_test_case.py +++ b/metricflow/test/integration/configured_test_case.py @@ -64,6 +64,7 @@ class Config: # noqa: D where_filter: Optional[str] = None limit: Optional[int] = None description: Optional[str] = None + min_max_only: bool = False class TestCaseParseException(Exception): diff --git a/metricflow/test/integration/test_cases/itest_dimensions.yaml b/metricflow/test/integration/test_cases/itest_dimensions.yaml index ed050c2233..ddb115847e 100644 --- a/metricflow/test/integration/test_cases/itest_dimensions.yaml +++ b/metricflow/test/integration/test_cases/itest_dimensions.yaml @@ -105,7 +105,7 @@ integration_test: --- integration_test: name: query_dimension_only - description: Query dimenension only + description: Query dimension only model: SIMPLE_MODEL group_bys: ["user__home_state"] check_query: | @@ -171,7 +171,7 @@ integration_test: --- integration_test: name: query_dimension_only_with_constraint - description: Query dimenension only + description: Query dimension only with a constraint model: SIMPLE_MODEL group_bys: ["user__home_state"] where_filter: "{{ render_dimension_template('user__home_state') }} = 'CA'" @@ -182,3 +182,57 @@ integration_test: WHERE u.home_state = 'CA' GROUP BY u.home_state +--- +integration_test: + name: min_max_only_categorical + description: Get min and max of a categorical dimension + model: SIMPLE_MODEL + group_bys: ["user__home_state"] + min_max_only: true + check_query: | + SELECT + MIN(user__home_state) AS min + , MAX(user__home_state) AS max + FROM ( + SELECT + u.home_state AS user__home_state + FROM {{ source_schema }}.dim_users u + GROUP BY + u.home_state + ) +--- +integration_test: + name: min_max_only_time + description: Get min and max of a time dimension + model: SIMPLE_MODEL + group_bys: ["verification__ds"] + min_max_only: true + check_query: | + SELECT + MIN(verification__ds__day) AS min + , MAX(verification__ds__day) AS max + FROM ( + SELECT + v.ds as verification__ds__day + FROM {{ source_schema }}.fct_id_verifications v + GROUP BY + v.ds + ) +--- +integration_test: + name: min_max_only_time_month + description: Get min and max of a time dimension with month granularity + model: SIMPLE_MODEL + group_bys: ["verification__ds__month"] + min_max_only: true + check_query: | + SELECT + MIN(verification__ds__month) AS min + , MAX(verification__ds__month) AS max + FROM ( + SELECT + {{ render_date_trunc("v.ds", TimeGranularity.MONTH) }} as verification__ds__month + FROM {{ source_schema }}.fct_id_verifications v + GROUP BY + {{ render_date_trunc("v.ds", TimeGranularity.MONTH) }} + )