Skip to content

Commit

Permalink
Add check query tests for time spine metrics with sub-daily grain
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Jul 30, 2024
1 parent 9203d45 commit 4e01f86
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -592,3 +592,43 @@ integration_test:
, metric_time__year
, t2mr
) subq_9
---
integration_test:
name: subdaily_cumulative_window_metric
description: test a subdaily cumulative window metric
model: SIMPLE_MODEL
metrics: ["subdaily_cumulative_window_metric"]
group_bys: ["metric_time__hour"]
check_query: |
SELECT
subq_3.ts AS metric_time__hour
, SUM(subq_1.archived_users) AS subdaily_cumulative_window_metric
FROM {{ source_schema }}.mf_time_spine_hour subq_3
INNER JOIN (
SELECT
{{ render_date_trunc("archived_at", TimeGranularity.HOUR) }} AS metric_time__hour
, 1 AS archived_users
FROM {{ source_schema }}.dim_users
) subq_1
ON (subq_1.metric_time__hour <= subq_3.ts) AND (subq_1.metric_time__hour > subq_3.ts - INTERVAL 3 hour)
GROUP BY subq_3.ts
---
integration_test:
name: subdaily_cumulative_grain_to_date_metric
description: test a subdaily cumulative grain_to_date metric
model: SIMPLE_MODEL
metrics: ["subdaily_cumulative_grain_to_date_metric"]
group_bys: ["metric_time__hour"]
check_query: |
SELECT
subq_3.ts AS metric_time__hour
, SUM(subq_1.archived_users) AS subdaily_cumulative_grain_to_date_metric
FROM {{ source_schema }}.mf_time_spine_hour subq_3
INNER JOIN (
SELECT
{{ render_date_trunc("archived_at", TimeGranularity.HOUR) }} AS metric_time__hour
, 1 AS archived_users
FROM {{ source_schema }}.dim_users
) subq_1
ON (subq_1.metric_time__hour <= subq_3.ts) AND (subq_1.metric_time__hour >= {{ render_date_trunc("subq_3.ts", TimeGranularity.HOUR) }})
GROUP BY subq_3.ts

0 comments on commit 4e01f86

Please sign in to comment.