diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window__plan0.sql index 062719124..3661b4478 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window__plan0.sql @@ -134,7 +134,7 @@ FROM ( , subq_9.ds__day__lead AS metric_time__day FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_2 AS ( + WITH cte_3 AS ( -- Get Custom Granularity Bounds SELECT time_spine_src_28006.ds AS ds__day @@ -183,13 +183,13 @@ FROM ( ) SELECT - cte_2.ds__day AS ds__day + cte_3.ds__day AS ds__day , CASE - WHEN DATE_ADD(CAST(subq_8.ds__alien_day__first_value__lead AS DATETIME), INTERVAL cte_2.ds__day__row_number - 1 day) <= subq_8.ds__alien_day__last_value__lead - THEN DATE_ADD(CAST(subq_8.ds__alien_day__first_value__lead AS DATETIME), INTERVAL cte_2.ds__day__row_number - 1 day) + WHEN DATE_ADD(CAST(subq_8.ds__alien_day__first_value__lead AS DATETIME), INTERVAL cte_3.ds__day__row_number - 1 day) <= subq_8.ds__alien_day__last_value__lead + THEN DATE_ADD(CAST(subq_8.ds__alien_day__first_value__lead AS DATETIME), INTERVAL cte_3.ds__day__row_number - 1 day) ELSE NULL END AS ds__day__lead - FROM cte_2 cte_2 + FROM cte_3 cte_3 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -199,10 +199,10 @@ FROM ( FROM ( -- Get Unique Rows for Custom Granularity Bounds SELECT - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value - FROM cte_2 cte_2 + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value + FROM cte_3 cte_3 GROUP BY ds__alien_day , ds__alien_day__first_value @@ -210,7 +210,7 @@ FROM ( ) subq_7 ) subq_8 ON - cte_2.ds__alien_day = subq_8.ds__alien_day + cte_3.ds__alien_day = subq_8.ds__alien_day ) subq_9 ) subq_10 ) subq_11 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window__plan0_optimized.sql index f9fcf051f..e2045ef2a 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window__plan0_optimized.sql @@ -16,7 +16,7 @@ FROM ( , SUM(subq_21.bookings) AS bookings FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_6 AS ( + WITH cte_16 AS ( -- Read From Time Spine 'mf_time_spine' -- Get Custom Granularity Bounds SELECT @@ -40,13 +40,13 @@ FROM ( ) SELECT - cte_6.ds__day AS ds__day + cte_16.ds__day AS ds__day , CASE - WHEN DATE_ADD(CAST(subq_24.ds__alien_day__first_value__lead AS DATETIME), INTERVAL cte_6.ds__day__row_number - 1 day) <= subq_24.ds__alien_day__last_value__lead - THEN DATE_ADD(CAST(subq_24.ds__alien_day__first_value__lead AS DATETIME), INTERVAL cte_6.ds__day__row_number - 1 day) + WHEN DATE_ADD(CAST(subq_24.ds__alien_day__first_value__lead AS DATETIME), INTERVAL cte_16.ds__day__row_number - 1 day) <= subq_24.ds__alien_day__last_value__lead + THEN DATE_ADD(CAST(subq_24.ds__alien_day__first_value__lead AS DATETIME), INTERVAL cte_16.ds__day__row_number - 1 day) ELSE NULL END AS ds__day__lead - FROM cte_6 cte_6 + FROM cte_16 cte_16 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -59,7 +59,7 @@ FROM ( ds__alien_day , ds__alien_day__first_value , ds__alien_day__last_value - FROM cte_6 cte_6 + FROM cte_16 cte_16 GROUP BY ds__alien_day , ds__alien_day__first_value @@ -67,7 +67,7 @@ FROM ( ) subq_23 ) subq_24 ON - cte_6.ds__alien_day = subq_24.ds__alien_day + cte_16.ds__alien_day = subq_24.ds__alien_day ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window_with_granularity_and_date_part__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window_with_granularity_and_date_part__plan0.sql index 0964048bc..c474aebc8 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window_with_granularity_and_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window_with_granularity_and_date_part__plan0.sql @@ -148,7 +148,7 @@ FROM ( , subq_9.ds__day__lead AS metric_time__day FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_2 AS ( + WITH cte_3 AS ( -- Get Custom Granularity Bounds SELECT time_spine_src_28006.ds AS ds__day @@ -197,13 +197,13 @@ FROM ( ) SELECT - cte_2.ds__day AS ds__day + cte_3.ds__day AS ds__day , CASE - WHEN DATE_ADD(CAST(subq_8.ds__alien_day__first_value__lead AS DATETIME), INTERVAL cte_2.ds__day__row_number - 1 day) <= subq_8.ds__alien_day__last_value__lead - THEN DATE_ADD(CAST(subq_8.ds__alien_day__first_value__lead AS DATETIME), INTERVAL cte_2.ds__day__row_number - 1 day) + WHEN DATE_ADD(CAST(subq_8.ds__alien_day__first_value__lead AS DATETIME), INTERVAL cte_3.ds__day__row_number - 1 day) <= subq_8.ds__alien_day__last_value__lead + THEN DATE_ADD(CAST(subq_8.ds__alien_day__first_value__lead AS DATETIME), INTERVAL cte_3.ds__day__row_number - 1 day) ELSE NULL END AS ds__day__lead - FROM cte_2 cte_2 + FROM cte_3 cte_3 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -213,10 +213,10 @@ FROM ( FROM ( -- Get Unique Rows for Custom Granularity Bounds SELECT - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value - FROM cte_2 cte_2 + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value + FROM cte_3 cte_3 GROUP BY ds__alien_day , ds__alien_day__first_value @@ -224,7 +224,7 @@ FROM ( ) subq_7 ) subq_8 ON - cte_2.ds__alien_day = subq_8.ds__alien_day + cte_3.ds__alien_day = subq_8.ds__alien_day ) subq_9 ) subq_10 ) subq_11 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql index a18001372..a6998f15a 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql @@ -21,7 +21,7 @@ FROM ( , SUM(subq_22.bookings) AS bookings FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_6 AS ( + WITH cte_17 AS ( -- Read From Time Spine 'mf_time_spine' -- Get Custom Granularity Bounds SELECT @@ -45,13 +45,13 @@ FROM ( ) SELECT - cte_6.ds__day AS ds__day + cte_17.ds__day AS ds__day , CASE - WHEN DATE_ADD(CAST(subq_25.ds__alien_day__first_value__lead AS DATETIME), INTERVAL cte_6.ds__day__row_number - 1 day) <= subq_25.ds__alien_day__last_value__lead - THEN DATE_ADD(CAST(subq_25.ds__alien_day__first_value__lead AS DATETIME), INTERVAL cte_6.ds__day__row_number - 1 day) + WHEN DATE_ADD(CAST(subq_25.ds__alien_day__first_value__lead AS DATETIME), INTERVAL cte_17.ds__day__row_number - 1 day) <= subq_25.ds__alien_day__last_value__lead + THEN DATE_ADD(CAST(subq_25.ds__alien_day__first_value__lead AS DATETIME), INTERVAL cte_17.ds__day__row_number - 1 day) ELSE NULL END AS ds__day__lead - FROM cte_6 cte_6 + FROM cte_17 cte_17 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -64,7 +64,7 @@ FROM ( ds__alien_day , ds__alien_day__first_value , ds__alien_day__last_value - FROM cte_6 cte_6 + FROM cte_17 cte_17 GROUP BY ds__alien_day , ds__alien_day__first_value @@ -72,7 +72,7 @@ FROM ( ) subq_24 ) subq_25 ON - cte_6.ds__alien_day = subq_25.ds__alien_day + cte_17.ds__alien_day = subq_25.ds__alien_day ) subq_26 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window_with_only_window_grain__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window_with_only_window_grain__plan0.sql index 6994a3e7d..1c9f140c1 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window_with_only_window_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window_with_only_window_grain__plan0.sql @@ -137,7 +137,7 @@ FROM ( , subq_4.metric_time__alien_day FROM ( -- Join Offset Custom Granularity to Base Granularity - WITH cte_2 AS ( + WITH cte_3 AS ( -- Read From Time Spine 'mf_time_spine' SELECT time_spine_src_28006.ds AS ds__day @@ -156,22 +156,22 @@ FROM ( ) SELECT - cte_2.ds__day AS ds__day + cte_3.ds__day AS ds__day , subq_3.ds__alien_day__lead AS metric_time__day , subq_3.ds__alien_day__lead AS booking__ds__alien_day , subq_3.ds__alien_day__lead AS metric_time__alien_day - FROM cte_2 cte_2 + FROM cte_3 cte_3 INNER JOIN ( -- Offset Custom Granularity SELECT - cte_2.ds__alien_day - , LEAD(cte_2.ds__alien_day, 1) OVER (ORDER BY cte_2.ds__alien_day) AS ds__alien_day__lead - FROM cte_2 cte_2 + cte_3.ds__alien_day + , LEAD(cte_3.ds__alien_day, 1) OVER (ORDER BY cte_3.ds__alien_day) AS ds__alien_day__lead + FROM cte_3 cte_3 GROUP BY ds__alien_day ) subq_3 ON - cte_2.ds__alien_day = subq_3.ds__alien_day + cte_3.ds__alien_day = subq_3.ds__alien_day ) subq_4 ) subq_5 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql index 137a00540..601db64da 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/BigQuery/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql @@ -18,7 +18,7 @@ FROM ( , SUM(subq_12.bookings) AS bookings FROM ( -- Join Offset Custom Granularity to Base Granularity - WITH cte_6 AS ( + WITH cte_16 AS ( -- Read From Time Spine 'mf_time_spine' SELECT ds AS ds__day @@ -27,21 +27,21 @@ FROM ( ) SELECT - cte_6.ds__day AS ds__day + cte_16.ds__day AS ds__day , subq_13.ds__alien_day__lead AS booking__ds__alien_day , subq_13.ds__alien_day__lead AS metric_time__alien_day - FROM cte_6 cte_6 + FROM cte_16 cte_16 INNER JOIN ( -- Offset Custom Granularity SELECT ds__alien_day , LEAD(ds__alien_day, 1) OVER (ORDER BY ds__alien_day) AS ds__alien_day__lead - FROM cte_6 cte_6 + FROM cte_16 cte_16 GROUP BY ds__alien_day ) subq_13 ON - cte_6.ds__alien_day = subq_13.ds__alien_day + cte_16.ds__alien_day = subq_13.ds__alien_day ) subq_14 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window__plan0.sql index 6eeb5f64e..60d54b8b6 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window__plan0.sql @@ -134,7 +134,7 @@ FROM ( , subq_9.ds__day__lead AS metric_time__day FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_2 AS ( + WITH cte_3 AS ( -- Get Custom Granularity Bounds SELECT time_spine_src_28006.ds AS ds__day @@ -183,13 +183,13 @@ FROM ( ) SELECT - cte_2.ds__day AS ds__day + cte_3.ds__day AS ds__day , CASE - WHEN DATEADD(day, (cte_2.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) <= subq_8.ds__alien_day__last_value__lead - THEN DATEADD(day, (cte_2.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) + WHEN DATEADD(day, (cte_3.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) <= subq_8.ds__alien_day__last_value__lead + THEN DATEADD(day, (cte_3.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) ELSE NULL END AS ds__day__lead - FROM cte_2 cte_2 + FROM cte_3 cte_3 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -199,18 +199,18 @@ FROM ( FROM ( -- Get Unique Rows for Custom Granularity Bounds SELECT - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value - FROM cte_2 cte_2 + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value + FROM cte_3 cte_3 GROUP BY - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value ) subq_7 ) subq_8 ON - cte_2.ds__alien_day = subq_8.ds__alien_day + cte_3.ds__alien_day = subq_8.ds__alien_day ) subq_9 ) subq_10 ) subq_11 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window__plan0_optimized.sql index aa5d0085c..aca4a72e2 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window__plan0_optimized.sql @@ -16,7 +16,7 @@ FROM ( , SUM(subq_21.bookings) AS bookings FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_6 AS ( + WITH cte_16 AS ( -- Read From Time Spine 'mf_time_spine' -- Get Custom Granularity Bounds SELECT @@ -40,13 +40,13 @@ FROM ( ) SELECT - cte_6.ds__day AS ds__day + cte_16.ds__day AS ds__day , CASE - WHEN DATEADD(day, (cte_6.ds__day__row_number - 1), subq_24.ds__alien_day__first_value__lead) <= subq_24.ds__alien_day__last_value__lead - THEN DATEADD(day, (cte_6.ds__day__row_number - 1), subq_24.ds__alien_day__first_value__lead) + WHEN DATEADD(day, (cte_16.ds__day__row_number - 1), subq_24.ds__alien_day__first_value__lead) <= subq_24.ds__alien_day__last_value__lead + THEN DATEADD(day, (cte_16.ds__day__row_number - 1), subq_24.ds__alien_day__first_value__lead) ELSE NULL END AS ds__day__lead - FROM cte_6 cte_6 + FROM cte_16 cte_16 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -59,7 +59,7 @@ FROM ( ds__alien_day , ds__alien_day__first_value , ds__alien_day__last_value - FROM cte_6 cte_6 + FROM cte_16 cte_16 GROUP BY ds__alien_day , ds__alien_day__first_value @@ -67,7 +67,7 @@ FROM ( ) subq_23 ) subq_24 ON - cte_6.ds__alien_day = subq_24.ds__alien_day + cte_16.ds__alien_day = subq_24.ds__alien_day ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window_with_granularity_and_date_part__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window_with_granularity_and_date_part__plan0.sql index bc7dda620..88a6c1465 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window_with_granularity_and_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window_with_granularity_and_date_part__plan0.sql @@ -148,7 +148,7 @@ FROM ( , subq_9.ds__day__lead AS metric_time__day FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_2 AS ( + WITH cte_3 AS ( -- Get Custom Granularity Bounds SELECT time_spine_src_28006.ds AS ds__day @@ -197,13 +197,13 @@ FROM ( ) SELECT - cte_2.ds__day AS ds__day + cte_3.ds__day AS ds__day , CASE - WHEN DATEADD(day, (cte_2.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) <= subq_8.ds__alien_day__last_value__lead - THEN DATEADD(day, (cte_2.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) + WHEN DATEADD(day, (cte_3.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) <= subq_8.ds__alien_day__last_value__lead + THEN DATEADD(day, (cte_3.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) ELSE NULL END AS ds__day__lead - FROM cte_2 cte_2 + FROM cte_3 cte_3 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -213,18 +213,18 @@ FROM ( FROM ( -- Get Unique Rows for Custom Granularity Bounds SELECT - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value - FROM cte_2 cte_2 + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value + FROM cte_3 cte_3 GROUP BY - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value ) subq_7 ) subq_8 ON - cte_2.ds__alien_day = subq_8.ds__alien_day + cte_3.ds__alien_day = subq_8.ds__alien_day ) subq_9 ) subq_10 ) subq_11 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql index 4a431e2d3..00529b2fc 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql @@ -21,7 +21,7 @@ FROM ( , SUM(subq_22.bookings) AS bookings FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_6 AS ( + WITH cte_17 AS ( -- Read From Time Spine 'mf_time_spine' -- Get Custom Granularity Bounds SELECT @@ -45,13 +45,13 @@ FROM ( ) SELECT - cte_6.ds__day AS ds__day + cte_17.ds__day AS ds__day , CASE - WHEN DATEADD(day, (cte_6.ds__day__row_number - 1), subq_25.ds__alien_day__first_value__lead) <= subq_25.ds__alien_day__last_value__lead - THEN DATEADD(day, (cte_6.ds__day__row_number - 1), subq_25.ds__alien_day__first_value__lead) + WHEN DATEADD(day, (cte_17.ds__day__row_number - 1), subq_25.ds__alien_day__first_value__lead) <= subq_25.ds__alien_day__last_value__lead + THEN DATEADD(day, (cte_17.ds__day__row_number - 1), subq_25.ds__alien_day__first_value__lead) ELSE NULL END AS ds__day__lead - FROM cte_6 cte_6 + FROM cte_17 cte_17 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -64,7 +64,7 @@ FROM ( ds__alien_day , ds__alien_day__first_value , ds__alien_day__last_value - FROM cte_6 cte_6 + FROM cte_17 cte_17 GROUP BY ds__alien_day , ds__alien_day__first_value @@ -72,7 +72,7 @@ FROM ( ) subq_24 ) subq_25 ON - cte_6.ds__alien_day = subq_25.ds__alien_day + cte_17.ds__alien_day = subq_25.ds__alien_day ) subq_26 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window_with_only_window_grain__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window_with_only_window_grain__plan0.sql index 883d14aa7..0402e5ab8 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window_with_only_window_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window_with_only_window_grain__plan0.sql @@ -137,7 +137,7 @@ FROM ( , subq_4.metric_time__alien_day FROM ( -- Join Offset Custom Granularity to Base Granularity - WITH cte_2 AS ( + WITH cte_3 AS ( -- Read From Time Spine 'mf_time_spine' SELECT time_spine_src_28006.ds AS ds__day @@ -156,22 +156,22 @@ FROM ( ) SELECT - cte_2.ds__day AS ds__day + cte_3.ds__day AS ds__day , subq_3.ds__alien_day__lead AS metric_time__day , subq_3.ds__alien_day__lead AS booking__ds__alien_day , subq_3.ds__alien_day__lead AS metric_time__alien_day - FROM cte_2 cte_2 + FROM cte_3 cte_3 INNER JOIN ( -- Offset Custom Granularity SELECT - cte_2.ds__alien_day - , LEAD(cte_2.ds__alien_day, 1) OVER (ORDER BY cte_2.ds__alien_day) AS ds__alien_day__lead - FROM cte_2 cte_2 + cte_3.ds__alien_day + , LEAD(cte_3.ds__alien_day, 1) OVER (ORDER BY cte_3.ds__alien_day) AS ds__alien_day__lead + FROM cte_3 cte_3 GROUP BY - cte_2.ds__alien_day + cte_3.ds__alien_day ) subq_3 ON - cte_2.ds__alien_day = subq_3.ds__alien_day + cte_3.ds__alien_day = subq_3.ds__alien_day ) subq_4 ) subq_5 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql index a33247d3b..fb0c67048 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Databricks/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql @@ -18,7 +18,7 @@ FROM ( , SUM(subq_12.bookings) AS bookings FROM ( -- Join Offset Custom Granularity to Base Granularity - WITH cte_6 AS ( + WITH cte_16 AS ( -- Read From Time Spine 'mf_time_spine' SELECT ds AS ds__day @@ -27,21 +27,21 @@ FROM ( ) SELECT - cte_6.ds__day AS ds__day + cte_16.ds__day AS ds__day , subq_13.ds__alien_day__lead AS booking__ds__alien_day , subq_13.ds__alien_day__lead AS metric_time__alien_day - FROM cte_6 cte_6 + FROM cte_16 cte_16 INNER JOIN ( -- Offset Custom Granularity SELECT ds__alien_day , LEAD(ds__alien_day, 1) OVER (ORDER BY ds__alien_day) AS ds__alien_day__lead - FROM cte_6 cte_6 + FROM cte_16 cte_16 GROUP BY ds__alien_day ) subq_13 ON - cte_6.ds__alien_day = subq_13.ds__alien_day + cte_16.ds__alien_day = subq_13.ds__alien_day ) subq_14 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window__plan0.sql index 23dc61816..20a935d0e 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window__plan0.sql @@ -134,7 +134,7 @@ FROM ( , subq_9.ds__day__lead AS metric_time__day FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_2 AS ( + WITH cte_3 AS ( -- Get Custom Granularity Bounds SELECT time_spine_src_28006.ds AS ds__day @@ -183,13 +183,13 @@ FROM ( ) SELECT - cte_2.ds__day AS ds__day + cte_3.ds__day AS ds__day , CASE - WHEN subq_8.ds__alien_day__first_value__lead + MAKE_INTERVAL(days => CAST ((cte_2.ds__day__row_number - 1) AS INTEGER)) <= subq_8.ds__alien_day__last_value__lead - THEN subq_8.ds__alien_day__first_value__lead + MAKE_INTERVAL(days => CAST ((cte_2.ds__day__row_number - 1) AS INTEGER)) + WHEN subq_8.ds__alien_day__first_value__lead + MAKE_INTERVAL(days => CAST ((cte_3.ds__day__row_number - 1) AS INTEGER)) <= subq_8.ds__alien_day__last_value__lead + THEN subq_8.ds__alien_day__first_value__lead + MAKE_INTERVAL(days => CAST ((cte_3.ds__day__row_number - 1) AS INTEGER)) ELSE NULL END AS ds__day__lead - FROM cte_2 cte_2 + FROM cte_3 cte_3 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -199,18 +199,18 @@ FROM ( FROM ( -- Get Unique Rows for Custom Granularity Bounds SELECT - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value - FROM cte_2 cte_2 + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value + FROM cte_3 cte_3 GROUP BY - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value ) subq_7 ) subq_8 ON - cte_2.ds__alien_day = subq_8.ds__alien_day + cte_3.ds__alien_day = subq_8.ds__alien_day ) subq_9 ) subq_10 ) subq_11 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window__plan0_optimized.sql index 5b6b12e3c..201b8f621 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window__plan0_optimized.sql @@ -16,7 +16,7 @@ FROM ( , SUM(subq_21.bookings) AS bookings FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_6 AS ( + WITH cte_16 AS ( -- Read From Time Spine 'mf_time_spine' -- Get Custom Granularity Bounds SELECT @@ -40,13 +40,13 @@ FROM ( ) SELECT - cte_6.ds__day AS ds__day + cte_16.ds__day AS ds__day , CASE - WHEN subq_24.ds__alien_day__first_value__lead + MAKE_INTERVAL(days => CAST ((cte_6.ds__day__row_number - 1) AS INTEGER)) <= subq_24.ds__alien_day__last_value__lead - THEN subq_24.ds__alien_day__first_value__lead + MAKE_INTERVAL(days => CAST ((cte_6.ds__day__row_number - 1) AS INTEGER)) + WHEN subq_24.ds__alien_day__first_value__lead + MAKE_INTERVAL(days => CAST ((cte_16.ds__day__row_number - 1) AS INTEGER)) <= subq_24.ds__alien_day__last_value__lead + THEN subq_24.ds__alien_day__first_value__lead + MAKE_INTERVAL(days => CAST ((cte_16.ds__day__row_number - 1) AS INTEGER)) ELSE NULL END AS ds__day__lead - FROM cte_6 cte_6 + FROM cte_16 cte_16 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -59,7 +59,7 @@ FROM ( ds__alien_day , ds__alien_day__first_value , ds__alien_day__last_value - FROM cte_6 cte_6 + FROM cte_16 cte_16 GROUP BY ds__alien_day , ds__alien_day__first_value @@ -67,7 +67,7 @@ FROM ( ) subq_23 ) subq_24 ON - cte_6.ds__alien_day = subq_24.ds__alien_day + cte_16.ds__alien_day = subq_24.ds__alien_day ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window_with_granularity_and_date_part__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window_with_granularity_and_date_part__plan0.sql index 89aaed5b0..9fc5d4259 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window_with_granularity_and_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window_with_granularity_and_date_part__plan0.sql @@ -148,7 +148,7 @@ FROM ( , subq_9.ds__day__lead AS metric_time__day FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_2 AS ( + WITH cte_3 AS ( -- Get Custom Granularity Bounds SELECT time_spine_src_28006.ds AS ds__day @@ -197,13 +197,13 @@ FROM ( ) SELECT - cte_2.ds__day AS ds__day + cte_3.ds__day AS ds__day , CASE - WHEN subq_8.ds__alien_day__first_value__lead + MAKE_INTERVAL(days => CAST ((cte_2.ds__day__row_number - 1) AS INTEGER)) <= subq_8.ds__alien_day__last_value__lead - THEN subq_8.ds__alien_day__first_value__lead + MAKE_INTERVAL(days => CAST ((cte_2.ds__day__row_number - 1) AS INTEGER)) + WHEN subq_8.ds__alien_day__first_value__lead + MAKE_INTERVAL(days => CAST ((cte_3.ds__day__row_number - 1) AS INTEGER)) <= subq_8.ds__alien_day__last_value__lead + THEN subq_8.ds__alien_day__first_value__lead + MAKE_INTERVAL(days => CAST ((cte_3.ds__day__row_number - 1) AS INTEGER)) ELSE NULL END AS ds__day__lead - FROM cte_2 cte_2 + FROM cte_3 cte_3 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -213,18 +213,18 @@ FROM ( FROM ( -- Get Unique Rows for Custom Granularity Bounds SELECT - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value - FROM cte_2 cte_2 + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value + FROM cte_3 cte_3 GROUP BY - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value ) subq_7 ) subq_8 ON - cte_2.ds__alien_day = subq_8.ds__alien_day + cte_3.ds__alien_day = subq_8.ds__alien_day ) subq_9 ) subq_10 ) subq_11 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql index 4506db936..f6fb2fd41 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql @@ -21,7 +21,7 @@ FROM ( , SUM(subq_22.bookings) AS bookings FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_6 AS ( + WITH cte_17 AS ( -- Read From Time Spine 'mf_time_spine' -- Get Custom Granularity Bounds SELECT @@ -45,13 +45,13 @@ FROM ( ) SELECT - cte_6.ds__day AS ds__day + cte_17.ds__day AS ds__day , CASE - WHEN subq_25.ds__alien_day__first_value__lead + MAKE_INTERVAL(days => CAST ((cte_6.ds__day__row_number - 1) AS INTEGER)) <= subq_25.ds__alien_day__last_value__lead - THEN subq_25.ds__alien_day__first_value__lead + MAKE_INTERVAL(days => CAST ((cte_6.ds__day__row_number - 1) AS INTEGER)) + WHEN subq_25.ds__alien_day__first_value__lead + MAKE_INTERVAL(days => CAST ((cte_17.ds__day__row_number - 1) AS INTEGER)) <= subq_25.ds__alien_day__last_value__lead + THEN subq_25.ds__alien_day__first_value__lead + MAKE_INTERVAL(days => CAST ((cte_17.ds__day__row_number - 1) AS INTEGER)) ELSE NULL END AS ds__day__lead - FROM cte_6 cte_6 + FROM cte_17 cte_17 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -64,7 +64,7 @@ FROM ( ds__alien_day , ds__alien_day__first_value , ds__alien_day__last_value - FROM cte_6 cte_6 + FROM cte_17 cte_17 GROUP BY ds__alien_day , ds__alien_day__first_value @@ -72,7 +72,7 @@ FROM ( ) subq_24 ) subq_25 ON - cte_6.ds__alien_day = subq_25.ds__alien_day + cte_17.ds__alien_day = subq_25.ds__alien_day ) subq_26 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window_with_only_window_grain__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window_with_only_window_grain__plan0.sql index 8bf920997..379eebcd8 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window_with_only_window_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window_with_only_window_grain__plan0.sql @@ -137,7 +137,7 @@ FROM ( , subq_4.metric_time__alien_day FROM ( -- Join Offset Custom Granularity to Base Granularity - WITH cte_2 AS ( + WITH cte_3 AS ( -- Read From Time Spine 'mf_time_spine' SELECT time_spine_src_28006.ds AS ds__day @@ -156,22 +156,22 @@ FROM ( ) SELECT - cte_2.ds__day AS ds__day + cte_3.ds__day AS ds__day , subq_3.ds__alien_day__lead AS metric_time__day , subq_3.ds__alien_day__lead AS booking__ds__alien_day , subq_3.ds__alien_day__lead AS metric_time__alien_day - FROM cte_2 cte_2 + FROM cte_3 cte_3 INNER JOIN ( -- Offset Custom Granularity SELECT - cte_2.ds__alien_day - , LEAD(cte_2.ds__alien_day, 1) OVER (ORDER BY cte_2.ds__alien_day) AS ds__alien_day__lead - FROM cte_2 cte_2 + cte_3.ds__alien_day + , LEAD(cte_3.ds__alien_day, 1) OVER (ORDER BY cte_3.ds__alien_day) AS ds__alien_day__lead + FROM cte_3 cte_3 GROUP BY - cte_2.ds__alien_day + cte_3.ds__alien_day ) subq_3 ON - cte_2.ds__alien_day = subq_3.ds__alien_day + cte_3.ds__alien_day = subq_3.ds__alien_day ) subq_4 ) subq_5 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql index 00c493983..f4a62004a 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Postgres/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql @@ -18,7 +18,7 @@ FROM ( , SUM(subq_12.bookings) AS bookings FROM ( -- Join Offset Custom Granularity to Base Granularity - WITH cte_6 AS ( + WITH cte_16 AS ( -- Read From Time Spine 'mf_time_spine' SELECT ds AS ds__day @@ -27,21 +27,21 @@ FROM ( ) SELECT - cte_6.ds__day AS ds__day + cte_16.ds__day AS ds__day , subq_13.ds__alien_day__lead AS booking__ds__alien_day , subq_13.ds__alien_day__lead AS metric_time__alien_day - FROM cte_6 cte_6 + FROM cte_16 cte_16 INNER JOIN ( -- Offset Custom Granularity SELECT ds__alien_day , LEAD(ds__alien_day, 1) OVER (ORDER BY ds__alien_day) AS ds__alien_day__lead - FROM cte_6 cte_6 + FROM cte_16 cte_16 GROUP BY ds__alien_day ) subq_13 ON - cte_6.ds__alien_day = subq_13.ds__alien_day + cte_16.ds__alien_day = subq_13.ds__alien_day ) subq_14 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window__plan0.sql index 5e8c72569..f361c831d 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window__plan0.sql @@ -134,7 +134,7 @@ FROM ( , subq_9.ds__day__lead AS metric_time__day FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_2 AS ( + WITH cte_3 AS ( -- Get Custom Granularity Bounds SELECT time_spine_src_28006.ds AS ds__day @@ -183,13 +183,13 @@ FROM ( ) SELECT - cte_2.ds__day AS ds__day + cte_3.ds__day AS ds__day , CASE - WHEN DATEADD(day, (cte_2.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) <= subq_8.ds__alien_day__last_value__lead - THEN DATEADD(day, (cte_2.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) + WHEN DATEADD(day, (cte_3.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) <= subq_8.ds__alien_day__last_value__lead + THEN DATEADD(day, (cte_3.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) ELSE NULL END AS ds__day__lead - FROM cte_2 cte_2 + FROM cte_3 cte_3 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -199,18 +199,18 @@ FROM ( FROM ( -- Get Unique Rows for Custom Granularity Bounds SELECT - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value - FROM cte_2 cte_2 + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value + FROM cte_3 cte_3 GROUP BY - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value ) subq_7 ) subq_8 ON - cte_2.ds__alien_day = subq_8.ds__alien_day + cte_3.ds__alien_day = subq_8.ds__alien_day ) subq_9 ) subq_10 ) subq_11 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window__plan0_optimized.sql index 2ef82404b..8b6e1bf23 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window__plan0_optimized.sql @@ -16,7 +16,7 @@ FROM ( , SUM(subq_21.bookings) AS bookings FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_6 AS ( + WITH cte_16 AS ( -- Read From Time Spine 'mf_time_spine' -- Get Custom Granularity Bounds SELECT @@ -40,13 +40,13 @@ FROM ( ) SELECT - cte_6.ds__day AS ds__day + cte_16.ds__day AS ds__day , CASE - WHEN DATEADD(day, (cte_6.ds__day__row_number - 1), subq_24.ds__alien_day__first_value__lead) <= subq_24.ds__alien_day__last_value__lead - THEN DATEADD(day, (cte_6.ds__day__row_number - 1), subq_24.ds__alien_day__first_value__lead) + WHEN DATEADD(day, (cte_16.ds__day__row_number - 1), subq_24.ds__alien_day__first_value__lead) <= subq_24.ds__alien_day__last_value__lead + THEN DATEADD(day, (cte_16.ds__day__row_number - 1), subq_24.ds__alien_day__first_value__lead) ELSE NULL END AS ds__day__lead - FROM cte_6 cte_6 + FROM cte_16 cte_16 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -59,7 +59,7 @@ FROM ( ds__alien_day , ds__alien_day__first_value , ds__alien_day__last_value - FROM cte_6 cte_6 + FROM cte_16 cte_16 GROUP BY ds__alien_day , ds__alien_day__first_value @@ -67,7 +67,7 @@ FROM ( ) subq_23 ) subq_24 ON - cte_6.ds__alien_day = subq_24.ds__alien_day + cte_16.ds__alien_day = subq_24.ds__alien_day ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window_with_granularity_and_date_part__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window_with_granularity_and_date_part__plan0.sql index 40239bc41..90635b601 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window_with_granularity_and_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window_with_granularity_and_date_part__plan0.sql @@ -148,7 +148,7 @@ FROM ( , subq_9.ds__day__lead AS metric_time__day FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_2 AS ( + WITH cte_3 AS ( -- Get Custom Granularity Bounds SELECT time_spine_src_28006.ds AS ds__day @@ -197,13 +197,13 @@ FROM ( ) SELECT - cte_2.ds__day AS ds__day + cte_3.ds__day AS ds__day , CASE - WHEN DATEADD(day, (cte_2.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) <= subq_8.ds__alien_day__last_value__lead - THEN DATEADD(day, (cte_2.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) + WHEN DATEADD(day, (cte_3.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) <= subq_8.ds__alien_day__last_value__lead + THEN DATEADD(day, (cte_3.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) ELSE NULL END AS ds__day__lead - FROM cte_2 cte_2 + FROM cte_3 cte_3 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -213,18 +213,18 @@ FROM ( FROM ( -- Get Unique Rows for Custom Granularity Bounds SELECT - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value - FROM cte_2 cte_2 + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value + FROM cte_3 cte_3 GROUP BY - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value ) subq_7 ) subq_8 ON - cte_2.ds__alien_day = subq_8.ds__alien_day + cte_3.ds__alien_day = subq_8.ds__alien_day ) subq_9 ) subq_10 ) subq_11 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql index d69034f57..b71b2dbb0 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql @@ -21,7 +21,7 @@ FROM ( , SUM(subq_22.bookings) AS bookings FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_6 AS ( + WITH cte_17 AS ( -- Read From Time Spine 'mf_time_spine' -- Get Custom Granularity Bounds SELECT @@ -45,13 +45,13 @@ FROM ( ) SELECT - cte_6.ds__day AS ds__day + cte_17.ds__day AS ds__day , CASE - WHEN DATEADD(day, (cte_6.ds__day__row_number - 1), subq_25.ds__alien_day__first_value__lead) <= subq_25.ds__alien_day__last_value__lead - THEN DATEADD(day, (cte_6.ds__day__row_number - 1), subq_25.ds__alien_day__first_value__lead) + WHEN DATEADD(day, (cte_17.ds__day__row_number - 1), subq_25.ds__alien_day__first_value__lead) <= subq_25.ds__alien_day__last_value__lead + THEN DATEADD(day, (cte_17.ds__day__row_number - 1), subq_25.ds__alien_day__first_value__lead) ELSE NULL END AS ds__day__lead - FROM cte_6 cte_6 + FROM cte_17 cte_17 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -64,7 +64,7 @@ FROM ( ds__alien_day , ds__alien_day__first_value , ds__alien_day__last_value - FROM cte_6 cte_6 + FROM cte_17 cte_17 GROUP BY ds__alien_day , ds__alien_day__first_value @@ -72,7 +72,7 @@ FROM ( ) subq_24 ) subq_25 ON - cte_6.ds__alien_day = subq_25.ds__alien_day + cte_17.ds__alien_day = subq_25.ds__alien_day ) subq_26 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window_with_only_window_grain__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window_with_only_window_grain__plan0.sql index 8be9e9b0c..a915388dd 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window_with_only_window_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window_with_only_window_grain__plan0.sql @@ -137,7 +137,7 @@ FROM ( , subq_4.metric_time__alien_day FROM ( -- Join Offset Custom Granularity to Base Granularity - WITH cte_2 AS ( + WITH cte_3 AS ( -- Read From Time Spine 'mf_time_spine' SELECT time_spine_src_28006.ds AS ds__day @@ -156,22 +156,22 @@ FROM ( ) SELECT - cte_2.ds__day AS ds__day + cte_3.ds__day AS ds__day , subq_3.ds__alien_day__lead AS metric_time__day , subq_3.ds__alien_day__lead AS booking__ds__alien_day , subq_3.ds__alien_day__lead AS metric_time__alien_day - FROM cte_2 cte_2 + FROM cte_3 cte_3 INNER JOIN ( -- Offset Custom Granularity SELECT - cte_2.ds__alien_day - , LEAD(cte_2.ds__alien_day, 1) OVER (ORDER BY cte_2.ds__alien_day) AS ds__alien_day__lead - FROM cte_2 cte_2 + cte_3.ds__alien_day + , LEAD(cte_3.ds__alien_day, 1) OVER (ORDER BY cte_3.ds__alien_day) AS ds__alien_day__lead + FROM cte_3 cte_3 GROUP BY - cte_2.ds__alien_day + cte_3.ds__alien_day ) subq_3 ON - cte_2.ds__alien_day = subq_3.ds__alien_day + cte_3.ds__alien_day = subq_3.ds__alien_day ) subq_4 ) subq_5 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql index 3abf54174..be6bb453c 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Redshift/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql @@ -18,7 +18,7 @@ FROM ( , SUM(subq_12.bookings) AS bookings FROM ( -- Join Offset Custom Granularity to Base Granularity - WITH cte_6 AS ( + WITH cte_16 AS ( -- Read From Time Spine 'mf_time_spine' SELECT ds AS ds__day @@ -27,21 +27,21 @@ FROM ( ) SELECT - cte_6.ds__day AS ds__day + cte_16.ds__day AS ds__day , subq_13.ds__alien_day__lead AS booking__ds__alien_day , subq_13.ds__alien_day__lead AS metric_time__alien_day - FROM cte_6 cte_6 + FROM cte_16 cte_16 INNER JOIN ( -- Offset Custom Granularity SELECT ds__alien_day , LEAD(ds__alien_day, 1) OVER (ORDER BY ds__alien_day) AS ds__alien_day__lead - FROM cte_6 cte_6 + FROM cte_16 cte_16 GROUP BY ds__alien_day ) subq_13 ON - cte_6.ds__alien_day = subq_13.ds__alien_day + cte_16.ds__alien_day = subq_13.ds__alien_day ) subq_14 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window__plan0.sql index 2f3a5efed..8c43bd258 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window__plan0.sql @@ -134,7 +134,7 @@ FROM ( , subq_9.ds__day__lead AS metric_time__day FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_2 AS ( + WITH cte_3 AS ( -- Get Custom Granularity Bounds SELECT time_spine_src_28006.ds AS ds__day @@ -183,13 +183,13 @@ FROM ( ) SELECT - cte_2.ds__day AS ds__day + cte_3.ds__day AS ds__day , CASE - WHEN DATEADD(day, (cte_2.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) <= subq_8.ds__alien_day__last_value__lead - THEN DATEADD(day, (cte_2.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) + WHEN DATEADD(day, (cte_3.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) <= subq_8.ds__alien_day__last_value__lead + THEN DATEADD(day, (cte_3.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) ELSE NULL END AS ds__day__lead - FROM cte_2 cte_2 + FROM cte_3 cte_3 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -199,18 +199,18 @@ FROM ( FROM ( -- Get Unique Rows for Custom Granularity Bounds SELECT - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value - FROM cte_2 cte_2 + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value + FROM cte_3 cte_3 GROUP BY - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value ) subq_7 ) subq_8 ON - cte_2.ds__alien_day = subq_8.ds__alien_day + cte_3.ds__alien_day = subq_8.ds__alien_day ) subq_9 ) subq_10 ) subq_11 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window__plan0_optimized.sql index 5129d1dcd..f3895126b 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window__plan0_optimized.sql @@ -16,7 +16,7 @@ FROM ( , SUM(subq_21.bookings) AS bookings FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_6 AS ( + WITH cte_16 AS ( -- Read From Time Spine 'mf_time_spine' -- Get Custom Granularity Bounds SELECT @@ -40,13 +40,13 @@ FROM ( ) SELECT - cte_6.ds__day AS ds__day + cte_16.ds__day AS ds__day , CASE - WHEN DATEADD(day, (cte_6.ds__day__row_number - 1), subq_24.ds__alien_day__first_value__lead) <= subq_24.ds__alien_day__last_value__lead - THEN DATEADD(day, (cte_6.ds__day__row_number - 1), subq_24.ds__alien_day__first_value__lead) + WHEN DATEADD(day, (cte_16.ds__day__row_number - 1), subq_24.ds__alien_day__first_value__lead) <= subq_24.ds__alien_day__last_value__lead + THEN DATEADD(day, (cte_16.ds__day__row_number - 1), subq_24.ds__alien_day__first_value__lead) ELSE NULL END AS ds__day__lead - FROM cte_6 cte_6 + FROM cte_16 cte_16 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -59,7 +59,7 @@ FROM ( ds__alien_day , ds__alien_day__first_value , ds__alien_day__last_value - FROM cte_6 cte_6 + FROM cte_16 cte_16 GROUP BY ds__alien_day , ds__alien_day__first_value @@ -67,7 +67,7 @@ FROM ( ) subq_23 ) subq_24 ON - cte_6.ds__alien_day = subq_24.ds__alien_day + cte_16.ds__alien_day = subq_24.ds__alien_day ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window_with_granularity_and_date_part__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window_with_granularity_and_date_part__plan0.sql index 4dfa5b734..39c816d40 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window_with_granularity_and_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window_with_granularity_and_date_part__plan0.sql @@ -148,7 +148,7 @@ FROM ( , subq_9.ds__day__lead AS metric_time__day FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_2 AS ( + WITH cte_3 AS ( -- Get Custom Granularity Bounds SELECT time_spine_src_28006.ds AS ds__day @@ -197,13 +197,13 @@ FROM ( ) SELECT - cte_2.ds__day AS ds__day + cte_3.ds__day AS ds__day , CASE - WHEN DATEADD(day, (cte_2.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) <= subq_8.ds__alien_day__last_value__lead - THEN DATEADD(day, (cte_2.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) + WHEN DATEADD(day, (cte_3.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) <= subq_8.ds__alien_day__last_value__lead + THEN DATEADD(day, (cte_3.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) ELSE NULL END AS ds__day__lead - FROM cte_2 cte_2 + FROM cte_3 cte_3 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -213,18 +213,18 @@ FROM ( FROM ( -- Get Unique Rows for Custom Granularity Bounds SELECT - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value - FROM cte_2 cte_2 + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value + FROM cte_3 cte_3 GROUP BY - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value ) subq_7 ) subq_8 ON - cte_2.ds__alien_day = subq_8.ds__alien_day + cte_3.ds__alien_day = subq_8.ds__alien_day ) subq_9 ) subq_10 ) subq_11 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql index bc7e619ca..77a78f6f7 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql @@ -21,7 +21,7 @@ FROM ( , SUM(subq_22.bookings) AS bookings FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_6 AS ( + WITH cte_17 AS ( -- Read From Time Spine 'mf_time_spine' -- Get Custom Granularity Bounds SELECT @@ -45,13 +45,13 @@ FROM ( ) SELECT - cte_6.ds__day AS ds__day + cte_17.ds__day AS ds__day , CASE - WHEN DATEADD(day, (cte_6.ds__day__row_number - 1), subq_25.ds__alien_day__first_value__lead) <= subq_25.ds__alien_day__last_value__lead - THEN DATEADD(day, (cte_6.ds__day__row_number - 1), subq_25.ds__alien_day__first_value__lead) + WHEN DATEADD(day, (cte_17.ds__day__row_number - 1), subq_25.ds__alien_day__first_value__lead) <= subq_25.ds__alien_day__last_value__lead + THEN DATEADD(day, (cte_17.ds__day__row_number - 1), subq_25.ds__alien_day__first_value__lead) ELSE NULL END AS ds__day__lead - FROM cte_6 cte_6 + FROM cte_17 cte_17 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -64,7 +64,7 @@ FROM ( ds__alien_day , ds__alien_day__first_value , ds__alien_day__last_value - FROM cte_6 cte_6 + FROM cte_17 cte_17 GROUP BY ds__alien_day , ds__alien_day__first_value @@ -72,7 +72,7 @@ FROM ( ) subq_24 ) subq_25 ON - cte_6.ds__alien_day = subq_25.ds__alien_day + cte_17.ds__alien_day = subq_25.ds__alien_day ) subq_26 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window_with_only_window_grain__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window_with_only_window_grain__plan0.sql index c3caa153b..687c63275 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window_with_only_window_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window_with_only_window_grain__plan0.sql @@ -137,7 +137,7 @@ FROM ( , subq_4.metric_time__alien_day FROM ( -- Join Offset Custom Granularity to Base Granularity - WITH cte_2 AS ( + WITH cte_3 AS ( -- Read From Time Spine 'mf_time_spine' SELECT time_spine_src_28006.ds AS ds__day @@ -156,22 +156,22 @@ FROM ( ) SELECT - cte_2.ds__day AS ds__day + cte_3.ds__day AS ds__day , subq_3.ds__alien_day__lead AS metric_time__day , subq_3.ds__alien_day__lead AS booking__ds__alien_day , subq_3.ds__alien_day__lead AS metric_time__alien_day - FROM cte_2 cte_2 + FROM cte_3 cte_3 INNER JOIN ( -- Offset Custom Granularity SELECT - cte_2.ds__alien_day - , LEAD(cte_2.ds__alien_day, 1) OVER (ORDER BY cte_2.ds__alien_day) AS ds__alien_day__lead - FROM cte_2 cte_2 + cte_3.ds__alien_day + , LEAD(cte_3.ds__alien_day, 1) OVER (ORDER BY cte_3.ds__alien_day) AS ds__alien_day__lead + FROM cte_3 cte_3 GROUP BY - cte_2.ds__alien_day + cte_3.ds__alien_day ) subq_3 ON - cte_2.ds__alien_day = subq_3.ds__alien_day + cte_3.ds__alien_day = subq_3.ds__alien_day ) subq_4 ) subq_5 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql index a67727250..a6098bf2c 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Snowflake/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql @@ -18,7 +18,7 @@ FROM ( , SUM(subq_12.bookings) AS bookings FROM ( -- Join Offset Custom Granularity to Base Granularity - WITH cte_6 AS ( + WITH cte_16 AS ( -- Read From Time Spine 'mf_time_spine' SELECT ds AS ds__day @@ -27,21 +27,21 @@ FROM ( ) SELECT - cte_6.ds__day AS ds__day + cte_16.ds__day AS ds__day , subq_13.ds__alien_day__lead AS booking__ds__alien_day , subq_13.ds__alien_day__lead AS metric_time__alien_day - FROM cte_6 cte_6 + FROM cte_16 cte_16 INNER JOIN ( -- Offset Custom Granularity SELECT ds__alien_day , LEAD(ds__alien_day, 1) OVER (ORDER BY ds__alien_day) AS ds__alien_day__lead - FROM cte_6 cte_6 + FROM cte_16 cte_16 GROUP BY ds__alien_day ) subq_13 ON - cte_6.ds__alien_day = subq_13.ds__alien_day + cte_16.ds__alien_day = subq_13.ds__alien_day ) subq_14 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window__plan0.sql index 71607e52c..09b7cb1e3 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window__plan0.sql @@ -134,7 +134,7 @@ FROM ( , subq_9.ds__day__lead AS metric_time__day FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_2 AS ( + WITH cte_3 AS ( -- Get Custom Granularity Bounds SELECT time_spine_src_28006.ds AS ds__day @@ -183,13 +183,13 @@ FROM ( ) SELECT - cte_2.ds__day AS ds__day + cte_3.ds__day AS ds__day , CASE - WHEN DATE_ADD('day', (cte_2.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) <= subq_8.ds__alien_day__last_value__lead - THEN DATE_ADD('day', (cte_2.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) + WHEN DATE_ADD('day', (cte_3.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) <= subq_8.ds__alien_day__last_value__lead + THEN DATE_ADD('day', (cte_3.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) ELSE NULL END AS ds__day__lead - FROM cte_2 cte_2 + FROM cte_3 cte_3 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -199,18 +199,18 @@ FROM ( FROM ( -- Get Unique Rows for Custom Granularity Bounds SELECT - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value - FROM cte_2 cte_2 + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value + FROM cte_3 cte_3 GROUP BY - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value ) subq_7 ) subq_8 ON - cte_2.ds__alien_day = subq_8.ds__alien_day + cte_3.ds__alien_day = subq_8.ds__alien_day ) subq_9 ) subq_10 ) subq_11 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window__plan0_optimized.sql index 9bc54bc0c..c17acf379 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window__plan0_optimized.sql @@ -16,7 +16,7 @@ FROM ( , SUM(subq_21.bookings) AS bookings FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_6 AS ( + WITH cte_16 AS ( -- Read From Time Spine 'mf_time_spine' -- Get Custom Granularity Bounds SELECT @@ -40,13 +40,13 @@ FROM ( ) SELECT - cte_6.ds__day AS ds__day + cte_16.ds__day AS ds__day , CASE - WHEN DATE_ADD('day', (cte_6.ds__day__row_number - 1), subq_24.ds__alien_day__first_value__lead) <= subq_24.ds__alien_day__last_value__lead - THEN DATE_ADD('day', (cte_6.ds__day__row_number - 1), subq_24.ds__alien_day__first_value__lead) + WHEN DATE_ADD('day', (cte_16.ds__day__row_number - 1), subq_24.ds__alien_day__first_value__lead) <= subq_24.ds__alien_day__last_value__lead + THEN DATE_ADD('day', (cte_16.ds__day__row_number - 1), subq_24.ds__alien_day__first_value__lead) ELSE NULL END AS ds__day__lead - FROM cte_6 cte_6 + FROM cte_16 cte_16 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -59,7 +59,7 @@ FROM ( ds__alien_day , ds__alien_day__first_value , ds__alien_day__last_value - FROM cte_6 cte_6 + FROM cte_16 cte_16 GROUP BY ds__alien_day , ds__alien_day__first_value @@ -67,7 +67,7 @@ FROM ( ) subq_23 ) subq_24 ON - cte_6.ds__alien_day = subq_24.ds__alien_day + cte_16.ds__alien_day = subq_24.ds__alien_day ) subq_25 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window_with_granularity_and_date_part__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window_with_granularity_and_date_part__plan0.sql index 4b6ffe154..54d91cea8 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window_with_granularity_and_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window_with_granularity_and_date_part__plan0.sql @@ -148,7 +148,7 @@ FROM ( , subq_9.ds__day__lead AS metric_time__day FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_2 AS ( + WITH cte_3 AS ( -- Get Custom Granularity Bounds SELECT time_spine_src_28006.ds AS ds__day @@ -197,13 +197,13 @@ FROM ( ) SELECT - cte_2.ds__day AS ds__day + cte_3.ds__day AS ds__day , CASE - WHEN DATE_ADD('day', (cte_2.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) <= subq_8.ds__alien_day__last_value__lead - THEN DATE_ADD('day', (cte_2.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) + WHEN DATE_ADD('day', (cte_3.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) <= subq_8.ds__alien_day__last_value__lead + THEN DATE_ADD('day', (cte_3.ds__day__row_number - 1), subq_8.ds__alien_day__first_value__lead) ELSE NULL END AS ds__day__lead - FROM cte_2 cte_2 + FROM cte_3 cte_3 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -213,18 +213,18 @@ FROM ( FROM ( -- Get Unique Rows for Custom Granularity Bounds SELECT - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value - FROM cte_2 cte_2 + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value + FROM cte_3 cte_3 GROUP BY - cte_2.ds__alien_day - , cte_2.ds__alien_day__first_value - , cte_2.ds__alien_day__last_value + cte_3.ds__alien_day + , cte_3.ds__alien_day__first_value + , cte_3.ds__alien_day__last_value ) subq_7 ) subq_8 ON - cte_2.ds__alien_day = subq_8.ds__alien_day + cte_3.ds__alien_day = subq_8.ds__alien_day ) subq_9 ) subq_10 ) subq_11 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql index 132d67243..e7de2711e 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window_with_granularity_and_date_part__plan0_optimized.sql @@ -21,7 +21,7 @@ FROM ( , SUM(subq_22.bookings) AS bookings FROM ( -- Offset Base Granularity By Custom Granularity Period(s) - WITH cte_6 AS ( + WITH cte_17 AS ( -- Read From Time Spine 'mf_time_spine' -- Get Custom Granularity Bounds SELECT @@ -45,13 +45,13 @@ FROM ( ) SELECT - cte_6.ds__day AS ds__day + cte_17.ds__day AS ds__day , CASE - WHEN DATE_ADD('day', (cte_6.ds__day__row_number - 1), subq_25.ds__alien_day__first_value__lead) <= subq_25.ds__alien_day__last_value__lead - THEN DATE_ADD('day', (cte_6.ds__day__row_number - 1), subq_25.ds__alien_day__first_value__lead) + WHEN DATE_ADD('day', (cte_17.ds__day__row_number - 1), subq_25.ds__alien_day__first_value__lead) <= subq_25.ds__alien_day__last_value__lead + THEN DATE_ADD('day', (cte_17.ds__day__row_number - 1), subq_25.ds__alien_day__first_value__lead) ELSE NULL END AS ds__day__lead - FROM cte_6 cte_6 + FROM cte_17 cte_17 INNER JOIN ( -- Offset Custom Granularity Bounds SELECT @@ -64,7 +64,7 @@ FROM ( ds__alien_day , ds__alien_day__first_value , ds__alien_day__last_value - FROM cte_6 cte_6 + FROM cte_17 cte_17 GROUP BY ds__alien_day , ds__alien_day__first_value @@ -72,7 +72,7 @@ FROM ( ) subq_24 ) subq_25 ON - cte_6.ds__alien_day = subq_25.ds__alien_day + cte_17.ds__alien_day = subq_25.ds__alien_day ) subq_26 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window_with_only_window_grain__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window_with_only_window_grain__plan0.sql index 2fd3fa3ac..35b62da65 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window_with_only_window_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window_with_only_window_grain__plan0.sql @@ -137,7 +137,7 @@ FROM ( , subq_4.metric_time__alien_day FROM ( -- Join Offset Custom Granularity to Base Granularity - WITH cte_2 AS ( + WITH cte_3 AS ( -- Read From Time Spine 'mf_time_spine' SELECT time_spine_src_28006.ds AS ds__day @@ -156,22 +156,22 @@ FROM ( ) SELECT - cte_2.ds__day AS ds__day + cte_3.ds__day AS ds__day , subq_3.ds__alien_day__lead AS metric_time__day , subq_3.ds__alien_day__lead AS booking__ds__alien_day , subq_3.ds__alien_day__lead AS metric_time__alien_day - FROM cte_2 cte_2 + FROM cte_3 cte_3 INNER JOIN ( -- Offset Custom Granularity SELECT - cte_2.ds__alien_day - , LEAD(cte_2.ds__alien_day, 1) OVER (ORDER BY cte_2.ds__alien_day) AS ds__alien_day__lead - FROM cte_2 cte_2 + cte_3.ds__alien_day + , LEAD(cte_3.ds__alien_day, 1) OVER (ORDER BY cte_3.ds__alien_day) AS ds__alien_day__lead + FROM cte_3 cte_3 GROUP BY - cte_2.ds__alien_day + cte_3.ds__alien_day ) subq_3 ON - cte_2.ds__alien_day = subq_3.ds__alien_day + cte_3.ds__alien_day = subq_3.ds__alien_day ) subq_4 ) subq_5 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql index 2933db075..91378b89e 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlPlan/Trino/test_custom_offset_window_with_only_window_grain__plan0_optimized.sql @@ -18,7 +18,7 @@ FROM ( , SUM(subq_12.bookings) AS bookings FROM ( -- Join Offset Custom Granularity to Base Granularity - WITH cte_6 AS ( + WITH cte_16 AS ( -- Read From Time Spine 'mf_time_spine' SELECT ds AS ds__day @@ -27,21 +27,21 @@ FROM ( ) SELECT - cte_6.ds__day AS ds__day + cte_16.ds__day AS ds__day , subq_13.ds__alien_day__lead AS booking__ds__alien_day , subq_13.ds__alien_day__lead AS metric_time__alien_day - FROM cte_6 cte_6 + FROM cte_16 cte_16 INNER JOIN ( -- Offset Custom Granularity SELECT ds__alien_day , LEAD(ds__alien_day, 1) OVER (ORDER BY ds__alien_day) AS ds__alien_day__lead - FROM cte_6 cte_6 + FROM cte_16 cte_16 GROUP BY ds__alien_day ) subq_13 ON - cte_6.ds__alien_day = subq_13.ds__alien_day + cte_16.ds__alien_day = subq_13.ds__alien_day ) subq_14 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source'