Skip to content

Commit

Permalink
Add check query tests for metric filters with single & double-hop in …
Browse files Browse the repository at this point in the history
…inner query
  • Loading branch information
courtneyholcomb committed May 11, 2024
1 parent 75bc587 commit db6b956
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests_metricflow/integration/test_cases/itest_metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2067,3 +2067,48 @@ integration_test:
) subq
ON l.listing_id = subq.listing_id
WHERE view__listing__views > 2
---
integration_test:
name: test_metric_filter_with_inner_query_single_hop_join
description: Query with a metric filter where the inner query uses a single-hop join
model: PARTITIONED_MULTI_HOP_JOIN_MODEL
metrics: ["third_hop_count"]
where_filter: "{{ render_metric_template('paraguayan_customers', ['customer_third_hop_id']) }} > 0"
check_query: |
SELECT
COUNT(DISTINCT t.customer_third_hop_id) AS third_hop_count
FROM {{ source_schema }}.third_hop_table t
LEFT OUTER JOIN (
SELECT
customer_third_hop_id
, SUM(1) AS paraguayan_customers
FROM {{ source_schema }}.customer_other_data c
WHERE country = 'paraguay'
GROUP BY customer_third_hop_id
) metric_subquery
ON t.customer_third_hop_id = metric_subquery.customer_third_hop_id
WHERE paraguayan_customers > 0
---
integration_test:
name: test_metric_filter_with_inner_query_multi_hop_join
description: Query with a metric filter where the inner query uses a two-hop join
model: PARTITIONED_MULTI_HOP_JOIN_MODEL
metrics: ["third_hop_count"]
where_filter: "{{ render_metric_template('txn_count', ['account_id__customer_id__customer_third_hop_id']) }} > 0"
check_query: |
SELECT
COUNT(DISTINCT t.customer_third_hop_id) AS third_hop_count
FROM {{ source_schema }}.third_hop_table t
LEFT OUTER JOIN (
SELECT
c.customer_third_hop_id
, SUM(a.txn_count) AS txn_count
FROM {{ source_schema }}.account_month_txns a
LEFT OUTER JOIN {{ source_schema }}.bridge_table b
ON (a.account_id = b.account_id) AND (DATE_TRUNC('day', a.ds_partitioned) = DATE_TRUNC('day', b.ds_partitioned))
LEFT OUTER JOIN {{ source_schema }}.customer_other_data c
ON b.customer_id = c.customer_id
GROUP BY c.customer_third_hop_id
) metric_subquery
ON t.customer_third_hop_id = metric_subquery.customer_third_hop_id
WHERE txn_count > 0

0 comments on commit db6b956

Please sign in to comment.