Skip to content

Commit 3c153b2

Browse files
committed
Update snapshots for other SQL engines.
1 parent f53fb2e commit 3c153b2

File tree

396 files changed

+19886
-14216
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

396 files changed

+19886
-14216
lines changed

tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,60 @@ docstring:
44
Test querying a derived metric with a cumulative input metric using non-default grains.
55
sql_engine: BigQuery
66
---
7-
-- Compute Metrics via Expressions
8-
SELECT
9-
metric_time__week
10-
, t2mr - 10 AS trailing_2_months_revenue_sub_10
11-
FROM (
12-
-- Re-aggregate Metric via Group By
7+
-- Read From CTE For node_id=cm_5
8+
WITH cm_4_cte AS (
9+
-- Compute Metrics via Expressions
10+
SELECT
11+
metric_time__week
12+
, txn_revenue AS t2mr
13+
FROM (
14+
-- Join Self Over Time Range
15+
-- Pass Only Elements: ['txn_revenue', 'metric_time__week', 'metric_time__day']
16+
-- Aggregate Measures
17+
SELECT
18+
subq_13.ds AS metric_time__day
19+
, DATETIME_TRUNC(subq_13.ds, isoweek) AS metric_time__week
20+
, SUM(revenue_src_28000.revenue) AS txn_revenue
21+
FROM ***************************.mf_time_spine subq_13
22+
INNER JOIN
23+
***************************.fct_revenue revenue_src_28000
24+
ON
25+
(
26+
DATETIME_TRUNC(revenue_src_28000.created_at, day) <= subq_13.ds
27+
) AND (
28+
DATETIME_TRUNC(revenue_src_28000.created_at, day) > DATE_SUB(CAST(subq_13.ds AS DATETIME), INTERVAL 2 month)
29+
)
30+
GROUP BY
31+
metric_time__day
32+
, metric_time__week
33+
) subq_16
34+
)
35+
36+
, cm_5_cte AS (
37+
-- Compute Metrics via Expressions
1338
SELECT
1439
metric_time__week
15-
, t2mr
40+
, t2mr - 10 AS trailing_2_months_revenue_sub_10
1641
FROM (
17-
-- Compute Metrics via Expressions
18-
-- Window Function for Metric Re-aggregation
42+
-- Re-aggregate Metric via Group By
1943
SELECT
2044
metric_time__week
21-
, AVG(txn_revenue) OVER (PARTITION BY metric_time__week) AS t2mr
45+
, t2mr
2246
FROM (
23-
-- Join Self Over Time Range
24-
-- Pass Only Elements: ['txn_revenue', 'metric_time__week', 'metric_time__day']
25-
-- Aggregate Measures
47+
-- Read From CTE For node_id=cm_4
48+
-- Window Function for Metric Re-aggregation
2649
SELECT
27-
subq_13.ds AS metric_time__day
28-
, DATETIME_TRUNC(subq_13.ds, isoweek) AS metric_time__week
29-
, SUM(revenue_src_28000.revenue) AS txn_revenue
30-
FROM ***************************.mf_time_spine subq_13
31-
INNER JOIN
32-
***************************.fct_revenue revenue_src_28000
33-
ON
34-
(
35-
DATETIME_TRUNC(revenue_src_28000.created_at, day) <= subq_13.ds
36-
) AND (
37-
DATETIME_TRUNC(revenue_src_28000.created_at, day) > DATE_SUB(CAST(subq_13.ds AS DATETIME), INTERVAL 2 month)
38-
)
39-
GROUP BY
40-
metric_time__day
41-
, metric_time__week
42-
) subq_16
43-
) subq_18
44-
GROUP BY
45-
metric_time__week
46-
, t2mr
47-
) subq_19
50+
metric_time__week
51+
, AVG(t2mr) OVER (PARTITION BY metric_time__week) AS t2mr
52+
FROM cm_4_cte cm_4_cte
53+
) subq_18
54+
GROUP BY
55+
metric_time__week
56+
, t2mr
57+
) subq_19
58+
)
59+
60+
SELECT
61+
metric_time__week AS metric_time__week
62+
, trailing_2_months_revenue_sub_10 AS trailing_2_months_revenue_sub_10
63+
FROM cm_5_cte cm_5_cte

tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,60 @@ docstring:
44
Test querying a derived metric with a cumulative input metric using non-default grains.
55
sql_engine: Databricks
66
---
7-
-- Compute Metrics via Expressions
8-
SELECT
9-
metric_time__week
10-
, t2mr - 10 AS trailing_2_months_revenue_sub_10
11-
FROM (
12-
-- Re-aggregate Metric via Group By
7+
-- Read From CTE For node_id=cm_5
8+
WITH cm_4_cte AS (
9+
-- Compute Metrics via Expressions
10+
SELECT
11+
metric_time__week
12+
, txn_revenue AS t2mr
13+
FROM (
14+
-- Join Self Over Time Range
15+
-- Pass Only Elements: ['txn_revenue', 'metric_time__week', 'metric_time__day']
16+
-- Aggregate Measures
17+
SELECT
18+
subq_13.ds AS metric_time__day
19+
, DATE_TRUNC('week', subq_13.ds) AS metric_time__week
20+
, SUM(revenue_src_28000.revenue) AS txn_revenue
21+
FROM ***************************.mf_time_spine subq_13
22+
INNER JOIN
23+
***************************.fct_revenue revenue_src_28000
24+
ON
25+
(
26+
DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_13.ds
27+
) AND (
28+
DATE_TRUNC('day', revenue_src_28000.created_at) > DATEADD(month, -2, subq_13.ds)
29+
)
30+
GROUP BY
31+
subq_13.ds
32+
, DATE_TRUNC('week', subq_13.ds)
33+
) subq_16
34+
)
35+
36+
, cm_5_cte AS (
37+
-- Compute Metrics via Expressions
1338
SELECT
1439
metric_time__week
15-
, t2mr
40+
, t2mr - 10 AS trailing_2_months_revenue_sub_10
1641
FROM (
17-
-- Compute Metrics via Expressions
18-
-- Window Function for Metric Re-aggregation
42+
-- Re-aggregate Metric via Group By
1943
SELECT
2044
metric_time__week
21-
, AVG(txn_revenue) OVER (PARTITION BY metric_time__week) AS t2mr
45+
, t2mr
2246
FROM (
23-
-- Join Self Over Time Range
24-
-- Pass Only Elements: ['txn_revenue', 'metric_time__week', 'metric_time__day']
25-
-- Aggregate Measures
47+
-- Read From CTE For node_id=cm_4
48+
-- Window Function for Metric Re-aggregation
2649
SELECT
27-
subq_13.ds AS metric_time__day
28-
, DATE_TRUNC('week', subq_13.ds) AS metric_time__week
29-
, SUM(revenue_src_28000.revenue) AS txn_revenue
30-
FROM ***************************.mf_time_spine subq_13
31-
INNER JOIN
32-
***************************.fct_revenue revenue_src_28000
33-
ON
34-
(
35-
DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_13.ds
36-
) AND (
37-
DATE_TRUNC('day', revenue_src_28000.created_at) > DATEADD(month, -2, subq_13.ds)
38-
)
39-
GROUP BY
40-
subq_13.ds
41-
, DATE_TRUNC('week', subq_13.ds)
42-
) subq_16
43-
) subq_18
44-
GROUP BY
45-
metric_time__week
46-
, t2mr
47-
) subq_19
50+
metric_time__week
51+
, AVG(t2mr) OVER (PARTITION BY metric_time__week) AS t2mr
52+
FROM cm_4_cte cm_4_cte
53+
) subq_18
54+
GROUP BY
55+
metric_time__week
56+
, t2mr
57+
) subq_19
58+
)
59+
60+
SELECT
61+
metric_time__week AS metric_time__week
62+
, trailing_2_months_revenue_sub_10 AS trailing_2_months_revenue_sub_10
63+
FROM cm_5_cte cm_5_cte

tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,60 @@ docstring:
44
Test querying a derived metric with a cumulative input metric using non-default grains.
55
sql_engine: Postgres
66
---
7-
-- Compute Metrics via Expressions
8-
SELECT
9-
metric_time__week
10-
, t2mr - 10 AS trailing_2_months_revenue_sub_10
11-
FROM (
12-
-- Re-aggregate Metric via Group By
7+
-- Read From CTE For node_id=cm_5
8+
WITH cm_4_cte AS (
9+
-- Compute Metrics via Expressions
10+
SELECT
11+
metric_time__week
12+
, txn_revenue AS t2mr
13+
FROM (
14+
-- Join Self Over Time Range
15+
-- Pass Only Elements: ['txn_revenue', 'metric_time__week', 'metric_time__day']
16+
-- Aggregate Measures
17+
SELECT
18+
subq_13.ds AS metric_time__day
19+
, DATE_TRUNC('week', subq_13.ds) AS metric_time__week
20+
, SUM(revenue_src_28000.revenue) AS txn_revenue
21+
FROM ***************************.mf_time_spine subq_13
22+
INNER JOIN
23+
***************************.fct_revenue revenue_src_28000
24+
ON
25+
(
26+
DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_13.ds
27+
) AND (
28+
DATE_TRUNC('day', revenue_src_28000.created_at) > subq_13.ds - MAKE_INTERVAL(months => 2)
29+
)
30+
GROUP BY
31+
subq_13.ds
32+
, DATE_TRUNC('week', subq_13.ds)
33+
) subq_16
34+
)
35+
36+
, cm_5_cte AS (
37+
-- Compute Metrics via Expressions
1338
SELECT
1439
metric_time__week
15-
, t2mr
40+
, t2mr - 10 AS trailing_2_months_revenue_sub_10
1641
FROM (
17-
-- Compute Metrics via Expressions
18-
-- Window Function for Metric Re-aggregation
42+
-- Re-aggregate Metric via Group By
1943
SELECT
2044
metric_time__week
21-
, AVG(txn_revenue) OVER (PARTITION BY metric_time__week) AS t2mr
45+
, t2mr
2246
FROM (
23-
-- Join Self Over Time Range
24-
-- Pass Only Elements: ['txn_revenue', 'metric_time__week', 'metric_time__day']
25-
-- Aggregate Measures
47+
-- Read From CTE For node_id=cm_4
48+
-- Window Function for Metric Re-aggregation
2649
SELECT
27-
subq_13.ds AS metric_time__day
28-
, DATE_TRUNC('week', subq_13.ds) AS metric_time__week
29-
, SUM(revenue_src_28000.revenue) AS txn_revenue
30-
FROM ***************************.mf_time_spine subq_13
31-
INNER JOIN
32-
***************************.fct_revenue revenue_src_28000
33-
ON
34-
(
35-
DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_13.ds
36-
) AND (
37-
DATE_TRUNC('day', revenue_src_28000.created_at) > subq_13.ds - MAKE_INTERVAL(months => 2)
38-
)
39-
GROUP BY
40-
subq_13.ds
41-
, DATE_TRUNC('week', subq_13.ds)
42-
) subq_16
43-
) subq_18
44-
GROUP BY
45-
metric_time__week
46-
, t2mr
47-
) subq_19
50+
metric_time__week
51+
, AVG(t2mr) OVER (PARTITION BY metric_time__week) AS t2mr
52+
FROM cm_4_cte cm_4_cte
53+
) subq_18
54+
GROUP BY
55+
metric_time__week
56+
, t2mr
57+
) subq_19
58+
)
59+
60+
SELECT
61+
metric_time__week AS metric_time__week
62+
, trailing_2_months_revenue_sub_10 AS trailing_2_months_revenue_sub_10
63+
FROM cm_5_cte cm_5_cte

tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,60 @@ docstring:
44
Test querying a derived metric with a cumulative input metric using non-default grains.
55
sql_engine: Redshift
66
---
7-
-- Compute Metrics via Expressions
8-
SELECT
9-
metric_time__week
10-
, t2mr - 10 AS trailing_2_months_revenue_sub_10
11-
FROM (
12-
-- Re-aggregate Metric via Group By
7+
-- Read From CTE For node_id=cm_5
8+
WITH cm_4_cte AS (
9+
-- Compute Metrics via Expressions
10+
SELECT
11+
metric_time__week
12+
, txn_revenue AS t2mr
13+
FROM (
14+
-- Join Self Over Time Range
15+
-- Pass Only Elements: ['txn_revenue', 'metric_time__week', 'metric_time__day']
16+
-- Aggregate Measures
17+
SELECT
18+
subq_13.ds AS metric_time__day
19+
, DATE_TRUNC('week', subq_13.ds) AS metric_time__week
20+
, SUM(revenue_src_28000.revenue) AS txn_revenue
21+
FROM ***************************.mf_time_spine subq_13
22+
INNER JOIN
23+
***************************.fct_revenue revenue_src_28000
24+
ON
25+
(
26+
DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_13.ds
27+
) AND (
28+
DATE_TRUNC('day', revenue_src_28000.created_at) > DATEADD(month, -2, subq_13.ds)
29+
)
30+
GROUP BY
31+
subq_13.ds
32+
, DATE_TRUNC('week', subq_13.ds)
33+
) subq_16
34+
)
35+
36+
, cm_5_cte AS (
37+
-- Compute Metrics via Expressions
1338
SELECT
1439
metric_time__week
15-
, t2mr
40+
, t2mr - 10 AS trailing_2_months_revenue_sub_10
1641
FROM (
17-
-- Compute Metrics via Expressions
18-
-- Window Function for Metric Re-aggregation
42+
-- Re-aggregate Metric via Group By
1943
SELECT
2044
metric_time__week
21-
, AVG(txn_revenue) OVER (PARTITION BY metric_time__week) AS t2mr
45+
, t2mr
2246
FROM (
23-
-- Join Self Over Time Range
24-
-- Pass Only Elements: ['txn_revenue', 'metric_time__week', 'metric_time__day']
25-
-- Aggregate Measures
47+
-- Read From CTE For node_id=cm_4
48+
-- Window Function for Metric Re-aggregation
2649
SELECT
27-
subq_13.ds AS metric_time__day
28-
, DATE_TRUNC('week', subq_13.ds) AS metric_time__week
29-
, SUM(revenue_src_28000.revenue) AS txn_revenue
30-
FROM ***************************.mf_time_spine subq_13
31-
INNER JOIN
32-
***************************.fct_revenue revenue_src_28000
33-
ON
34-
(
35-
DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_13.ds
36-
) AND (
37-
DATE_TRUNC('day', revenue_src_28000.created_at) > DATEADD(month, -2, subq_13.ds)
38-
)
39-
GROUP BY
40-
subq_13.ds
41-
, DATE_TRUNC('week', subq_13.ds)
42-
) subq_16
43-
) subq_18
44-
GROUP BY
45-
metric_time__week
46-
, t2mr
47-
) subq_19
50+
metric_time__week
51+
, AVG(t2mr) OVER (PARTITION BY metric_time__week) AS t2mr
52+
FROM cm_4_cte cm_4_cte
53+
) subq_18
54+
GROUP BY
55+
metric_time__week
56+
, t2mr
57+
) subq_19
58+
)
59+
60+
SELECT
61+
metric_time__week AS metric_time__week
62+
, trailing_2_months_revenue_sub_10 AS trailing_2_months_revenue_sub_10
63+
FROM cm_5_cte cm_5_cte

0 commit comments

Comments
 (0)