From 98597ef3708789a1af7dd2d8cae14b56be1f4a5f Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Thu, 25 Jan 2024 21:07:29 -0800 Subject: [PATCH] Integratoin test --- .../test_cases/itest_cumulative_metric.yaml | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/metricflow/test/integration/test_cases/itest_cumulative_metric.yaml b/metricflow/test/integration/test_cases/itest_cumulative_metric.yaml index 521af2bb87..a854eb2846 100644 --- a/metricflow/test/integration/test_cases/itest_cumulative_metric.yaml +++ b/metricflow/test/integration/test_cases/itest_cumulative_metric.yaml @@ -384,3 +384,31 @@ integration_test: GROUP BY subq_3.metric_time__month ORDER BY subq_3.metric_time__month +--- +integration_test: + name: cumulative_metric_with_agg_time_dimension + description: Query a cumulative metric with its agg_time_dimension and a time constraint. + model: SIMPLE_MODEL + metrics: ["trailing_2_months_revenue"] + group_bys: ["revenue_instance__ds__day"] + order_bys: ["revenue_instance__ds__day"] + where_filter: '{{ render_time_constraint("revenue_instance__ds__day", "2020-03-05", "2021-01-04") }}' + check_query: | + SELECT + SUM(b.txn_revenue) as trailing_2_months_revenue + , a.ds AS revenue_instance__ds__day + FROM ( + SELECT ds + FROM {{ mf_time_spine_source }} + WHERE {{ render_time_constraint("ds", "2020-01-05", "2021-01-04") }} + ) a + INNER JOIN ( + SELECT + revenue as txn_revenue + , created_at AS ds + FROM {{ source_schema }}.fct_revenue + ) b + ON b.ds <= a.ds AND b.ds > {{ render_date_sub("a", "ds", 2, TimeGranularity.MONTH) }} + WHERE {{ render_time_constraint("a.ds", "2020-03-05", "2021-01-04") }} + GROUP BY a.ds + ORDER BY a.ds