diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0.sql index bf773b3597..601900bcd7 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , subq_4.ref_bookings AS ref_bookings - , subq_9.bookings AS bookings + , MAX(subq_4.ref_bookings) AS ref_bookings + , MAX(subq_9.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_8.metric_time__day @@ -441,13 +441,7 @@ FROM ( ) subq_8 ) subq_9 ON - ( - subq_4.metric_time__day = subq_9.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_9.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_9.metric_time__day + GROUP BY + metric_time__day ) subq_10 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0_optimized.sql index 90acc82428..b0d8d0b304 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) AS metric_time__day - , subq_15.ref_bookings AS ref_bookings - , subq_20.bookings AS bookings + , MAX(subq_15.ref_bookings) AS ref_bookings + , MAX(subq_20.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__day ) subq_15 - INNER JOIN ( + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -47,13 +47,7 @@ FROM ( metric_time__day ) subq_20 ON - ( - subq_15.metric_time__day = subq_20.metric_time__day - ) OR ( - ( - subq_15.metric_time__day IS NULL - ) AND ( - subq_20.metric_time__day IS NULL - ) - ) + subq_15.metric_time__day = subq_20.metric_time__day + GROUP BY + metric_time__day ) subq_21 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql index f33a1995b1..f03d500002 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , subq_4.bookings AS bookings - , subq_12.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__day @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__day = subq_12.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_12.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_12.metric_time__day + GROUP BY + metric_time__day ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index 808e5ad197..7eef401bbe 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , subq_18.bookings AS bookings - , subq_26.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__day ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -51,13 +51,7 @@ FROM ( metric_time__day ) subq_26 ON - ( - subq_18.metric_time__day = subq_26.metric_time__day - ) OR ( - ( - subq_18.metric_time__day IS NULL - ) AND ( - subq_26.metric_time__day IS NULL - ) - ) + subq_18.metric_time__day = subq_26.metric_time__day + GROUP BY + metric_time__day ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index 810d00f620..44823a15e3 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) AS metric_time__week - , subq_4.bookings AS bookings - , subq_12.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( metric_time__week ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__week @@ -542,13 +542,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__week = subq_12.metric_time__week - ) OR ( - ( - subq_4.metric_time__week IS NULL - ) AND ( - subq_12.metric_time__week IS NULL - ) - ) + subq_4.metric_time__week = subq_12.metric_time__week + GROUP BY + metric_time__week ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index e60f75c802..a2b43bfa72 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) AS metric_time__week - , subq_18.bookings AS bookings - , subq_26.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__week ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__week'] @@ -52,13 +52,7 @@ FROM ( metric_time__week ) subq_26 ON - ( - subq_18.metric_time__week = subq_26.metric_time__week - ) OR ( - ( - subq_18.metric_time__week IS NULL - ) AND ( - subq_26.metric_time__week IS NULL - ) - ) + subq_18.metric_time__week = subq_26.metric_time__week + GROUP BY + metric_time__week ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql index 815071a5eb..d0fb01c279 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , subq_4.bookings AS bookings - , subq_12.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__day @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__day = subq_12.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_12.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_12.metric_time__day + GROUP BY + metric_time__day ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0_optimized.sql index 10852db154..397b1bd968 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , subq_18.bookings AS bookings - , subq_26.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__day ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -51,13 +51,7 @@ FROM ( metric_time__day ) subq_26 ON - ( - subq_18.metric_time__day = subq_26.metric_time__day - ) OR ( - ( - subq_18.metric_time__day IS NULL - ) AND ( - subq_26.metric_time__day IS NULL - ) - ) + subq_18.metric_time__day = subq_26.metric_time__day + GROUP BY + metric_time__day ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 8dfcac05e2..7f6a988e25 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) AS metric_time__quarter - , subq_4.bookings AS bookings - , subq_12.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( metric_time__quarter ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__quarter @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__quarter = subq_12.metric_time__quarter - ) OR ( - ( - subq_4.metric_time__quarter IS NULL - ) AND ( - subq_12.metric_time__quarter IS NULL - ) - ) + subq_4.metric_time__quarter = subq_12.metric_time__quarter + GROUP BY + metric_time__quarter ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index 3d1eeb5c25..0b6326c173 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) AS metric_time__quarter - , subq_18.bookings AS bookings - , subq_26.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__quarter ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__quarter'] @@ -51,13 +51,7 @@ FROM ( metric_time__quarter ) subq_26 ON - ( - subq_18.metric_time__quarter = subq_26.metric_time__quarter - ) OR ( - ( - subq_18.metric_time__quarter IS NULL - ) AND ( - subq_26.metric_time__quarter IS NULL - ) - ) + subq_18.metric_time__quarter = subq_26.metric_time__quarter + GROUP BY + metric_time__quarter ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index b3f9730639..3c9cdf8bec 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , subq_7.month_start_bookings AS month_start_bookings - , subq_15.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_7.month_start_bookings) AS month_start_bookings + , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -324,7 +324,7 @@ FROM ( metric_time__day ) subq_6 ) subq_7 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_14.metric_time__day @@ -641,13 +641,7 @@ FROM ( ) subq_14 ) subq_15 ON - ( - subq_7.metric_time__day = subq_15.metric_time__day - ) OR ( - ( - subq_7.metric_time__day IS NULL - ) AND ( - subq_15.metric_time__day IS NULL - ) - ) + subq_7.metric_time__day = subq_15.metric_time__day + GROUP BY + metric_time__day ) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index d9ee2344b2..503310614c 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , subq_24.month_start_bookings AS month_start_bookings - , subq_32.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_24.month_start_bookings) AS month_start_bookings + , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: @@ -31,7 +31,7 @@ FROM ( GROUP BY metric_time__day ) subq_24 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -55,13 +55,7 @@ FROM ( metric_time__day ) subq_32 ON - ( - subq_24.metric_time__day = subq_32.metric_time__day - ) OR ( - ( - subq_24.metric_time__day IS NULL - ) AND ( - subq_32.metric_time__day IS NULL - ) - ) + subq_24.metric_time__day = subq_32.metric_time__day + GROUP BY + metric_time__day ) subq_33 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index ccb62c6ffb..d09a6065af 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) AS metric_time__year - , subq_7.month_start_bookings AS month_start_bookings - , subq_15.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_7.month_start_bookings) AS month_start_bookings + , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -325,7 +325,7 @@ FROM ( metric_time__year ) subq_6 ) subq_7 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_14.metric_time__year @@ -642,13 +642,7 @@ FROM ( ) subq_14 ) subq_15 ON - ( - subq_7.metric_time__year = subq_15.metric_time__year - ) OR ( - ( - subq_7.metric_time__year IS NULL - ) AND ( - subq_15.metric_time__year IS NULL - ) - ) + subq_7.metric_time__year = subq_15.metric_time__year + GROUP BY + metric_time__year ) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index e0ea67dae8..30d82361e0 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) AS metric_time__year - , subq_24.month_start_bookings AS month_start_bookings - , subq_32.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_24.month_start_bookings) AS month_start_bookings + , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: @@ -32,7 +32,7 @@ FROM ( GROUP BY metric_time__year ) subq_24 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__year'] @@ -56,13 +56,7 @@ FROM ( metric_time__year ) subq_32 ON - ( - subq_24.metric_time__year = subq_32.metric_time__year - ) OR ( - ( - subq_24.metric_time__year IS NULL - ) AND ( - subq_32.metric_time__year IS NULL - ) - ) + subq_24.metric_time__year = subq_32.metric_time__year + GROUP BY + metric_time__year ) subq_33 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0.sql index 2d23a71b28..9432f82a2f 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) AS metric_time__day - , subq_11.non_referred AS non_referred - , subq_16.instant AS instant - , subq_21.bookings AS bookings + , MAX(subq_11.non_referred) AS non_referred + , MAX(subq_16.instant) AS instant + , MAX(subq_21.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -18,8 +18,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , subq_4.ref_bookings AS ref_bookings - , subq_9.bookings AS bookings + , MAX(subq_4.ref_bookings) AS ref_bookings + , MAX(subq_9.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -236,7 +236,7 @@ FROM ( metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_8.metric_time__day @@ -453,18 +453,12 @@ FROM ( ) subq_8 ) subq_9 ON - ( - subq_4.metric_time__day = subq_9.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_9.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_9.metric_time__day + GROUP BY + metric_time__day ) subq_10 ) subq_11 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_15.metric_time__day @@ -681,16 +675,8 @@ FROM ( ) subq_15 ) subq_16 ON - ( - subq_11.metric_time__day = subq_16.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_16.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_11.metric_time__day = subq_16.metric_time__day + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_20.metric_time__day @@ -907,13 +893,7 @@ FROM ( ) subq_20 ) subq_21 ON - ( - subq_11.metric_time__day = subq_21.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_21.metric_time__day IS NULL - ) - ) + COALESCE(subq_11.metric_time__day, subq_16.metric_time__day) = subq_21.metric_time__day + GROUP BY + metric_time__day ) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0_optimized.sql index ea71adb2e4..9dd7154226 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0_optimized.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) AS metric_time__day - , subq_34.non_referred AS non_referred - , subq_39.instant AS instant - , subq_44.bookings AS bookings + , MAX(subq_34.non_referred) AS non_referred + , MAX(subq_39.instant) AS instant + , MAX(subq_44.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -18,8 +18,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , subq_27.ref_bookings AS ref_bookings - , subq_32.bookings AS bookings + , MAX(subq_27.ref_bookings) AS ref_bookings + , MAX(subq_32.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -39,7 +39,7 @@ FROM ( GROUP BY metric_time__day ) subq_27 - INNER JOIN ( + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -59,18 +59,12 @@ FROM ( metric_time__day ) subq_32 ON - ( - subq_27.metric_time__day = subq_32.metric_time__day - ) OR ( - ( - subq_27.metric_time__day IS NULL - ) AND ( - subq_32.metric_time__day IS NULL - ) - ) + subq_27.metric_time__day = subq_32.metric_time__day + GROUP BY + metric_time__day ) subq_33 ) subq_34 - INNER JOIN ( + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -90,16 +84,8 @@ FROM ( metric_time__day ) subq_39 ON - ( - subq_34.metric_time__day = subq_39.metric_time__day - ) OR ( - ( - subq_34.metric_time__day IS NULL - ) AND ( - subq_39.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_34.metric_time__day = subq_39.metric_time__day + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -119,13 +105,7 @@ FROM ( metric_time__day ) subq_44 ON - ( - subq_34.metric_time__day = subq_44.metric_time__day - ) OR ( - ( - subq_34.metric_time__day IS NULL - ) AND ( - subq_44.metric_time__day IS NULL - ) - ) + COALESCE(subq_34.metric_time__day, subq_39.metric_time__day) = subq_44.metric_time__day + GROUP BY + metric_time__day ) subq_45 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric__plan0.sql index 097834a44e..453868aaa2 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , subq_4.ref_bookings AS ref_bookings - , subq_9.bookings AS bookings + , MAX(subq_4.ref_bookings) AS ref_bookings + , MAX(subq_9.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_8.metric_time__day @@ -441,13 +441,7 @@ FROM ( ) subq_8 ) subq_9 ON - ( - subq_4.metric_time__day = subq_9.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_9.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_9.metric_time__day + GROUP BY + COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) ) subq_10 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric__plan0_optimized.sql index ace6863100..f7d37d45b3 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) AS metric_time__day - , subq_15.ref_bookings AS ref_bookings - , subq_20.bookings AS bookings + , MAX(subq_15.ref_bookings) AS ref_bookings + , MAX(subq_20.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__day ) subq_15 - INNER JOIN ( + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -47,13 +47,7 @@ FROM ( metric_time__day ) subq_20 ON - ( - subq_15.metric_time__day = subq_20.metric_time__day - ) OR ( - ( - subq_15.metric_time__day IS NULL - ) AND ( - subq_20.metric_time__day IS NULL - ) - ) + subq_15.metric_time__day = subq_20.metric_time__day + GROUP BY + COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) ) subq_21 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql index 046b1c3478..76852df7e0 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , subq_4.bookings AS bookings - , subq_12.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__day @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__day = subq_12.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_12.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_12.metric_time__day + GROUP BY + COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index a952516e96..6d1b17b416 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , subq_18.bookings AS bookings - , subq_26.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__day ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -51,13 +51,7 @@ FROM ( subq_22.ds ) subq_26 ON - ( - subq_18.metric_time__day = subq_26.metric_time__day - ) OR ( - ( - subq_18.metric_time__day IS NULL - ) AND ( - subq_26.metric_time__day IS NULL - ) - ) + subq_18.metric_time__day = subq_26.metric_time__day + GROUP BY + COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index a708ce4a8e..4ca9c85eb2 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) AS metric_time__week - , subq_4.bookings AS bookings - , subq_12.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__week ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__week @@ -542,13 +542,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__week = subq_12.metric_time__week - ) OR ( - ( - subq_4.metric_time__week IS NULL - ) AND ( - subq_12.metric_time__week IS NULL - ) - ) + subq_4.metric_time__week = subq_12.metric_time__week + GROUP BY + COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index e5a7e1789c..5b18fcfa5f 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) AS metric_time__week - , subq_18.bookings AS bookings - , subq_26.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__week ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__week'] @@ -52,13 +52,7 @@ FROM ( DATE_TRUNC('week', subq_22.ds) ) subq_26 ON - ( - subq_18.metric_time__week = subq_26.metric_time__week - ) OR ( - ( - subq_18.metric_time__week IS NULL - ) AND ( - subq_26.metric_time__week IS NULL - ) - ) + subq_18.metric_time__week = subq_26.metric_time__week + GROUP BY + COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql index 92b03bebe8..a08f661fd7 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , subq_4.bookings AS bookings - , subq_12.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__day @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__day = subq_12.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_12.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_12.metric_time__day + GROUP BY + COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0_optimized.sql index d79d809654..a01f18c65d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , subq_18.bookings AS bookings - , subq_26.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__day ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -51,13 +51,7 @@ FROM ( subq_22.ds ) subq_26 ON - ( - subq_18.metric_time__day = subq_26.metric_time__day - ) OR ( - ( - subq_18.metric_time__day IS NULL - ) AND ( - subq_26.metric_time__day IS NULL - ) - ) + subq_18.metric_time__day = subq_26.metric_time__day + GROUP BY + COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql index aca3ea0065..86edbbf9bc 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) AS metric_time__quarter - , subq_4.bookings AS bookings - , subq_12.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__quarter ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__quarter @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__quarter = subq_12.metric_time__quarter - ) OR ( - ( - subq_4.metric_time__quarter IS NULL - ) AND ( - subq_12.metric_time__quarter IS NULL - ) - ) + subq_4.metric_time__quarter = subq_12.metric_time__quarter + GROUP BY + COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index bbdb2547b7..10ccf3e20b 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) AS metric_time__quarter - , subq_18.bookings AS bookings - , subq_26.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__quarter ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__quarter'] @@ -51,13 +51,7 @@ FROM ( DATE_TRUNC('quarter', subq_22.ds) ) subq_26 ON - ( - subq_18.metric_time__quarter = subq_26.metric_time__quarter - ) OR ( - ( - subq_18.metric_time__quarter IS NULL - ) AND ( - subq_26.metric_time__quarter IS NULL - ) - ) + subq_18.metric_time__quarter = subq_26.metric_time__quarter + GROUP BY + COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 8545ddd49d..6230a73553 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , subq_7.month_start_bookings AS month_start_bookings - , subq_15.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_7.month_start_bookings) AS month_start_bookings + , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -324,7 +324,7 @@ FROM ( subq_5.metric_time__day ) subq_6 ) subq_7 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_14.metric_time__day @@ -641,13 +641,7 @@ FROM ( ) subq_14 ) subq_15 ON - ( - subq_7.metric_time__day = subq_15.metric_time__day - ) OR ( - ( - subq_7.metric_time__day IS NULL - ) AND ( - subq_15.metric_time__day IS NULL - ) - ) + subq_7.metric_time__day = subq_15.metric_time__day + GROUP BY + COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) ) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 3f57ba0cbf..91dc642b1b 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , subq_24.month_start_bookings AS month_start_bookings - , subq_32.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_24.month_start_bookings) AS month_start_bookings + , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: @@ -31,7 +31,7 @@ FROM ( GROUP BY subq_20.ds ) subq_24 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -55,13 +55,7 @@ FROM ( subq_28.ds ) subq_32 ON - ( - subq_24.metric_time__day = subq_32.metric_time__day - ) OR ( - ( - subq_24.metric_time__day IS NULL - ) AND ( - subq_32.metric_time__day IS NULL - ) - ) + subq_24.metric_time__day = subq_32.metric_time__day + GROUP BY + COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) ) subq_33 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index 189201fc45..e28765e766 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) AS metric_time__year - , subq_7.month_start_bookings AS month_start_bookings - , subq_15.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_7.month_start_bookings) AS month_start_bookings + , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -325,7 +325,7 @@ FROM ( subq_5.metric_time__year ) subq_6 ) subq_7 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_14.metric_time__year @@ -642,13 +642,7 @@ FROM ( ) subq_14 ) subq_15 ON - ( - subq_7.metric_time__year = subq_15.metric_time__year - ) OR ( - ( - subq_7.metric_time__year IS NULL - ) AND ( - subq_15.metric_time__year IS NULL - ) - ) + subq_7.metric_time__year = subq_15.metric_time__year + GROUP BY + COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) ) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 40dd779220..f06da5a3a2 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) AS metric_time__year - , subq_24.month_start_bookings AS month_start_bookings - , subq_32.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_24.month_start_bookings) AS month_start_bookings + , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: @@ -32,7 +32,7 @@ FROM ( GROUP BY DATE_TRUNC('year', subq_20.ds) ) subq_24 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__year'] @@ -56,13 +56,7 @@ FROM ( DATE_TRUNC('year', subq_28.ds) ) subq_32 ON - ( - subq_24.metric_time__year = subq_32.metric_time__year - ) OR ( - ( - subq_24.metric_time__year IS NULL - ) AND ( - subq_32.metric_time__year IS NULL - ) - ) + subq_24.metric_time__year = subq_32.metric_time__year + GROUP BY + COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) ) subq_33 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0.sql index 0bcc1c2e9e..061321a32e 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) AS metric_time__day - , subq_11.non_referred AS non_referred - , subq_16.instant AS instant - , subq_21.bookings AS bookings + , MAX(subq_11.non_referred) AS non_referred + , MAX(subq_16.instant) AS instant + , MAX(subq_21.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -18,8 +18,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , subq_4.ref_bookings AS ref_bookings - , subq_9.bookings AS bookings + , MAX(subq_4.ref_bookings) AS ref_bookings + , MAX(subq_9.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -236,7 +236,7 @@ FROM ( subq_2.metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_8.metric_time__day @@ -453,18 +453,12 @@ FROM ( ) subq_8 ) subq_9 ON - ( - subq_4.metric_time__day = subq_9.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_9.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_9.metric_time__day + GROUP BY + COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) ) subq_10 ) subq_11 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_15.metric_time__day @@ -681,16 +675,8 @@ FROM ( ) subq_15 ) subq_16 ON - ( - subq_11.metric_time__day = subq_16.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_16.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_11.metric_time__day = subq_16.metric_time__day + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_20.metric_time__day @@ -907,13 +893,7 @@ FROM ( ) subq_20 ) subq_21 ON - ( - subq_11.metric_time__day = subq_21.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_21.metric_time__day IS NULL - ) - ) + COALESCE(subq_11.metric_time__day, subq_16.metric_time__day) = subq_21.metric_time__day + GROUP BY + COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) ) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0_optimized.sql index 519c4b6ea5..86124d9091 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0_optimized.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) AS metric_time__day - , subq_34.non_referred AS non_referred - , subq_39.instant AS instant - , subq_44.bookings AS bookings + , MAX(subq_34.non_referred) AS non_referred + , MAX(subq_39.instant) AS instant + , MAX(subq_44.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -18,8 +18,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , subq_27.ref_bookings AS ref_bookings - , subq_32.bookings AS bookings + , MAX(subq_27.ref_bookings) AS ref_bookings + , MAX(subq_32.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -39,7 +39,7 @@ FROM ( GROUP BY metric_time__day ) subq_27 - INNER JOIN ( + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -59,18 +59,12 @@ FROM ( metric_time__day ) subq_32 ON - ( - subq_27.metric_time__day = subq_32.metric_time__day - ) OR ( - ( - subq_27.metric_time__day IS NULL - ) AND ( - subq_32.metric_time__day IS NULL - ) - ) + subq_27.metric_time__day = subq_32.metric_time__day + GROUP BY + COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) ) subq_33 ) subq_34 - INNER JOIN ( + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -90,16 +84,8 @@ FROM ( metric_time__day ) subq_39 ON - ( - subq_34.metric_time__day = subq_39.metric_time__day - ) OR ( - ( - subq_34.metric_time__day IS NULL - ) AND ( - subq_39.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_34.metric_time__day = subq_39.metric_time__day + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -119,13 +105,7 @@ FROM ( metric_time__day ) subq_44 ON - ( - subq_34.metric_time__day = subq_44.metric_time__day - ) OR ( - ( - subq_34.metric_time__day IS NULL - ) AND ( - subq_44.metric_time__day IS NULL - ) - ) + COALESCE(subq_34.metric_time__day, subq_39.metric_time__day) = subq_44.metric_time__day + GROUP BY + COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) ) subq_45 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric__plan0.sql index 127ebba768..85eee899d7 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , subq_4.ref_bookings AS ref_bookings - , subq_9.bookings AS bookings + , MAX(subq_4.ref_bookings) AS ref_bookings + , MAX(subq_9.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_8.metric_time__day @@ -441,13 +441,7 @@ FROM ( ) subq_8 ) subq_9 ON - ( - subq_4.metric_time__day = subq_9.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_9.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_9.metric_time__day + GROUP BY + COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) ) subq_10 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric__plan0_optimized.sql index ace6863100..f7d37d45b3 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) AS metric_time__day - , subq_15.ref_bookings AS ref_bookings - , subq_20.bookings AS bookings + , MAX(subq_15.ref_bookings) AS ref_bookings + , MAX(subq_20.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__day ) subq_15 - INNER JOIN ( + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -47,13 +47,7 @@ FROM ( metric_time__day ) subq_20 ON - ( - subq_15.metric_time__day = subq_20.metric_time__day - ) OR ( - ( - subq_15.metric_time__day IS NULL - ) AND ( - subq_20.metric_time__day IS NULL - ) - ) + subq_15.metric_time__day = subq_20.metric_time__day + GROUP BY + COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) ) subq_21 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql index 9ee6e81037..d8bb186c28 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , subq_4.bookings AS bookings - , subq_12.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__day @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__day = subq_12.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_12.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_12.metric_time__day + GROUP BY + COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index a952516e96..6d1b17b416 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , subq_18.bookings AS bookings - , subq_26.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__day ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -51,13 +51,7 @@ FROM ( subq_22.ds ) subq_26 ON - ( - subq_18.metric_time__day = subq_26.metric_time__day - ) OR ( - ( - subq_18.metric_time__day IS NULL - ) AND ( - subq_26.metric_time__day IS NULL - ) - ) + subq_18.metric_time__day = subq_26.metric_time__day + GROUP BY + COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index b526384e42..9e51107f26 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) AS metric_time__week - , subq_4.bookings AS bookings - , subq_12.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__week ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__week @@ -542,13 +542,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__week = subq_12.metric_time__week - ) OR ( - ( - subq_4.metric_time__week IS NULL - ) AND ( - subq_12.metric_time__week IS NULL - ) - ) + subq_4.metric_time__week = subq_12.metric_time__week + GROUP BY + COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index e5a7e1789c..5b18fcfa5f 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) AS metric_time__week - , subq_18.bookings AS bookings - , subq_26.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__week ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__week'] @@ -52,13 +52,7 @@ FROM ( DATE_TRUNC('week', subq_22.ds) ) subq_26 ON - ( - subq_18.metric_time__week = subq_26.metric_time__week - ) OR ( - ( - subq_18.metric_time__week IS NULL - ) AND ( - subq_26.metric_time__week IS NULL - ) - ) + subq_18.metric_time__week = subq_26.metric_time__week + GROUP BY + COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql index b256be0127..69941e528e 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , subq_4.bookings AS bookings - , subq_12.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__day @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__day = subq_12.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_12.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_12.metric_time__day + GROUP BY + COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0_optimized.sql index 2f47d03f76..7b84983917 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , subq_18.bookings AS bookings - , subq_26.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__day ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -51,13 +51,7 @@ FROM ( subq_22.ds ) subq_26 ON - ( - subq_18.metric_time__day = subq_26.metric_time__day - ) OR ( - ( - subq_18.metric_time__day IS NULL - ) AND ( - subq_26.metric_time__day IS NULL - ) - ) + subq_18.metric_time__day = subq_26.metric_time__day + GROUP BY + COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql index c646f155e6..f36d2d9cec 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) AS metric_time__quarter - , subq_4.bookings AS bookings - , subq_12.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__quarter ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__quarter @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__quarter = subq_12.metric_time__quarter - ) OR ( - ( - subq_4.metric_time__quarter IS NULL - ) AND ( - subq_12.metric_time__quarter IS NULL - ) - ) + subq_4.metric_time__quarter = subq_12.metric_time__quarter + GROUP BY + COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index b664ba9129..a18d3b4423 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) AS metric_time__quarter - , subq_18.bookings AS bookings - , subq_26.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__quarter ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__quarter'] @@ -51,13 +51,7 @@ FROM ( DATE_TRUNC('quarter', subq_22.ds) ) subq_26 ON - ( - subq_18.metric_time__quarter = subq_26.metric_time__quarter - ) OR ( - ( - subq_18.metric_time__quarter IS NULL - ) AND ( - subq_26.metric_time__quarter IS NULL - ) - ) + subq_18.metric_time__quarter = subq_26.metric_time__quarter + GROUP BY + COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 854407ab73..04623e0e7c 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , subq_7.month_start_bookings AS month_start_bookings - , subq_15.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_7.month_start_bookings) AS month_start_bookings + , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -324,7 +324,7 @@ FROM ( subq_5.metric_time__day ) subq_6 ) subq_7 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_14.metric_time__day @@ -641,13 +641,7 @@ FROM ( ) subq_14 ) subq_15 ON - ( - subq_7.metric_time__day = subq_15.metric_time__day - ) OR ( - ( - subq_7.metric_time__day IS NULL - ) AND ( - subq_15.metric_time__day IS NULL - ) - ) + subq_7.metric_time__day = subq_15.metric_time__day + GROUP BY + COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) ) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 35a3e9fade..dcb2c47e2f 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , subq_24.month_start_bookings AS month_start_bookings - , subq_32.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_24.month_start_bookings) AS month_start_bookings + , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: @@ -31,7 +31,7 @@ FROM ( GROUP BY subq_20.ds ) subq_24 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -55,13 +55,7 @@ FROM ( subq_28.ds ) subq_32 ON - ( - subq_24.metric_time__day = subq_32.metric_time__day - ) OR ( - ( - subq_24.metric_time__day IS NULL - ) AND ( - subq_32.metric_time__day IS NULL - ) - ) + subq_24.metric_time__day = subq_32.metric_time__day + GROUP BY + COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) ) subq_33 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index 479ca37998..ba6d756625 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) AS metric_time__year - , subq_7.month_start_bookings AS month_start_bookings - , subq_15.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_7.month_start_bookings) AS month_start_bookings + , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -325,7 +325,7 @@ FROM ( subq_5.metric_time__year ) subq_6 ) subq_7 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_14.metric_time__year @@ -642,13 +642,7 @@ FROM ( ) subq_14 ) subq_15 ON - ( - subq_7.metric_time__year = subq_15.metric_time__year - ) OR ( - ( - subq_7.metric_time__year IS NULL - ) AND ( - subq_15.metric_time__year IS NULL - ) - ) + subq_7.metric_time__year = subq_15.metric_time__year + GROUP BY + COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) ) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index e76f579ff2..6aa850f36a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) AS metric_time__year - , subq_24.month_start_bookings AS month_start_bookings - , subq_32.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_24.month_start_bookings) AS month_start_bookings + , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: @@ -32,7 +32,7 @@ FROM ( GROUP BY DATE_TRUNC('year', subq_20.ds) ) subq_24 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__year'] @@ -56,13 +56,7 @@ FROM ( DATE_TRUNC('year', subq_28.ds) ) subq_32 ON - ( - subq_24.metric_time__year = subq_32.metric_time__year - ) OR ( - ( - subq_24.metric_time__year IS NULL - ) AND ( - subq_32.metric_time__year IS NULL - ) - ) + subq_24.metric_time__year = subq_32.metric_time__year + GROUP BY + COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) ) subq_33 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0.sql index d7ab098327..0e23b840ec 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) AS metric_time__day - , subq_11.non_referred AS non_referred - , subq_16.instant AS instant - , subq_21.bookings AS bookings + , MAX(subq_11.non_referred) AS non_referred + , MAX(subq_16.instant) AS instant + , MAX(subq_21.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -18,8 +18,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , subq_4.ref_bookings AS ref_bookings - , subq_9.bookings AS bookings + , MAX(subq_4.ref_bookings) AS ref_bookings + , MAX(subq_9.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -236,7 +236,7 @@ FROM ( subq_2.metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_8.metric_time__day @@ -453,18 +453,12 @@ FROM ( ) subq_8 ) subq_9 ON - ( - subq_4.metric_time__day = subq_9.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_9.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_9.metric_time__day + GROUP BY + COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) ) subq_10 ) subq_11 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_15.metric_time__day @@ -681,16 +675,8 @@ FROM ( ) subq_15 ) subq_16 ON - ( - subq_11.metric_time__day = subq_16.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_16.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_11.metric_time__day = subq_16.metric_time__day + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_20.metric_time__day @@ -907,13 +893,7 @@ FROM ( ) subq_20 ) subq_21 ON - ( - subq_11.metric_time__day = subq_21.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_21.metric_time__day IS NULL - ) - ) + COALESCE(subq_11.metric_time__day, subq_16.metric_time__day) = subq_21.metric_time__day + GROUP BY + COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) ) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0_optimized.sql index 519c4b6ea5..86124d9091 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0_optimized.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) AS metric_time__day - , subq_34.non_referred AS non_referred - , subq_39.instant AS instant - , subq_44.bookings AS bookings + , MAX(subq_34.non_referred) AS non_referred + , MAX(subq_39.instant) AS instant + , MAX(subq_44.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -18,8 +18,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , subq_27.ref_bookings AS ref_bookings - , subq_32.bookings AS bookings + , MAX(subq_27.ref_bookings) AS ref_bookings + , MAX(subq_32.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -39,7 +39,7 @@ FROM ( GROUP BY metric_time__day ) subq_27 - INNER JOIN ( + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -59,18 +59,12 @@ FROM ( metric_time__day ) subq_32 ON - ( - subq_27.metric_time__day = subq_32.metric_time__day - ) OR ( - ( - subq_27.metric_time__day IS NULL - ) AND ( - subq_32.metric_time__day IS NULL - ) - ) + subq_27.metric_time__day = subq_32.metric_time__day + GROUP BY + COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) ) subq_33 ) subq_34 - INNER JOIN ( + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -90,16 +84,8 @@ FROM ( metric_time__day ) subq_39 ON - ( - subq_34.metric_time__day = subq_39.metric_time__day - ) OR ( - ( - subq_34.metric_time__day IS NULL - ) AND ( - subq_39.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_34.metric_time__day = subq_39.metric_time__day + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -119,13 +105,7 @@ FROM ( metric_time__day ) subq_44 ON - ( - subq_34.metric_time__day = subq_44.metric_time__day - ) OR ( - ( - subq_34.metric_time__day IS NULL - ) AND ( - subq_44.metric_time__day IS NULL - ) - ) + COALESCE(subq_34.metric_time__day, subq_39.metric_time__day) = subq_44.metric_time__day + GROUP BY + COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) ) subq_45 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric__plan0.sql index 4a797b4999..5534156eee 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , subq_4.ref_bookings AS ref_bookings - , subq_9.bookings AS bookings + , MAX(subq_4.ref_bookings) AS ref_bookings + , MAX(subq_9.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_8.metric_time__day @@ -441,13 +441,7 @@ FROM ( ) subq_8 ) subq_9 ON - ( - subq_4.metric_time__day = subq_9.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_9.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_9.metric_time__day + GROUP BY + COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) ) subq_10 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric__plan0_optimized.sql index ace6863100..f7d37d45b3 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) AS metric_time__day - , subq_15.ref_bookings AS ref_bookings - , subq_20.bookings AS bookings + , MAX(subq_15.ref_bookings) AS ref_bookings + , MAX(subq_20.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__day ) subq_15 - INNER JOIN ( + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -47,13 +47,7 @@ FROM ( metric_time__day ) subq_20 ON - ( - subq_15.metric_time__day = subq_20.metric_time__day - ) OR ( - ( - subq_15.metric_time__day IS NULL - ) AND ( - subq_20.metric_time__day IS NULL - ) - ) + subq_15.metric_time__day = subq_20.metric_time__day + GROUP BY + COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) ) subq_21 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql index e65aca953b..1e21685347 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , subq_4.bookings AS bookings - , subq_12.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__day @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__day = subq_12.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_12.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_12.metric_time__day + GROUP BY + COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index a952516e96..6d1b17b416 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , subq_18.bookings AS bookings - , subq_26.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__day ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -51,13 +51,7 @@ FROM ( subq_22.ds ) subq_26 ON - ( - subq_18.metric_time__day = subq_26.metric_time__day - ) OR ( - ( - subq_18.metric_time__day IS NULL - ) AND ( - subq_26.metric_time__day IS NULL - ) - ) + subq_18.metric_time__day = subq_26.metric_time__day + GROUP BY + COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index 677a5a4997..9aa59d72d5 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) AS metric_time__week - , subq_4.bookings AS bookings - , subq_12.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__week ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__week @@ -542,13 +542,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__week = subq_12.metric_time__week - ) OR ( - ( - subq_4.metric_time__week IS NULL - ) AND ( - subq_12.metric_time__week IS NULL - ) - ) + subq_4.metric_time__week = subq_12.metric_time__week + GROUP BY + COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index e5a7e1789c..5b18fcfa5f 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) AS metric_time__week - , subq_18.bookings AS bookings - , subq_26.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__week ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__week'] @@ -52,13 +52,7 @@ FROM ( DATE_TRUNC('week', subq_22.ds) ) subq_26 ON - ( - subq_18.metric_time__week = subq_26.metric_time__week - ) OR ( - ( - subq_18.metric_time__week IS NULL - ) AND ( - subq_26.metric_time__week IS NULL - ) - ) + subq_18.metric_time__week = subq_26.metric_time__week + GROUP BY + COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql index 690a431516..e650c49b60 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , subq_4.bookings AS bookings - , subq_12.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__day @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__day = subq_12.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_12.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_12.metric_time__day + GROUP BY + COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0_optimized.sql index d79d809654..a01f18c65d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , subq_18.bookings AS bookings - , subq_26.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__day ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -51,13 +51,7 @@ FROM ( subq_22.ds ) subq_26 ON - ( - subq_18.metric_time__day = subq_26.metric_time__day - ) OR ( - ( - subq_18.metric_time__day IS NULL - ) AND ( - subq_26.metric_time__day IS NULL - ) - ) + subq_18.metric_time__day = subq_26.metric_time__day + GROUP BY + COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql index d24e2ac551..832b087043 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) AS metric_time__quarter - , subq_4.bookings AS bookings - , subq_12.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__quarter ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__quarter @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__quarter = subq_12.metric_time__quarter - ) OR ( - ( - subq_4.metric_time__quarter IS NULL - ) AND ( - subq_12.metric_time__quarter IS NULL - ) - ) + subq_4.metric_time__quarter = subq_12.metric_time__quarter + GROUP BY + COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index bbdb2547b7..10ccf3e20b 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) AS metric_time__quarter - , subq_18.bookings AS bookings - , subq_26.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__quarter ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__quarter'] @@ -51,13 +51,7 @@ FROM ( DATE_TRUNC('quarter', subq_22.ds) ) subq_26 ON - ( - subq_18.metric_time__quarter = subq_26.metric_time__quarter - ) OR ( - ( - subq_18.metric_time__quarter IS NULL - ) AND ( - subq_26.metric_time__quarter IS NULL - ) - ) + subq_18.metric_time__quarter = subq_26.metric_time__quarter + GROUP BY + COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 336dc22c6f..a704ef1eab 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , subq_7.month_start_bookings AS month_start_bookings - , subq_15.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_7.month_start_bookings) AS month_start_bookings + , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -324,7 +324,7 @@ FROM ( subq_5.metric_time__day ) subq_6 ) subq_7 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_14.metric_time__day @@ -641,13 +641,7 @@ FROM ( ) subq_14 ) subq_15 ON - ( - subq_7.metric_time__day = subq_15.metric_time__day - ) OR ( - ( - subq_7.metric_time__day IS NULL - ) AND ( - subq_15.metric_time__day IS NULL - ) - ) + subq_7.metric_time__day = subq_15.metric_time__day + GROUP BY + COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) ) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 3f57ba0cbf..91dc642b1b 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , subq_24.month_start_bookings AS month_start_bookings - , subq_32.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_24.month_start_bookings) AS month_start_bookings + , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: @@ -31,7 +31,7 @@ FROM ( GROUP BY subq_20.ds ) subq_24 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -55,13 +55,7 @@ FROM ( subq_28.ds ) subq_32 ON - ( - subq_24.metric_time__day = subq_32.metric_time__day - ) OR ( - ( - subq_24.metric_time__day IS NULL - ) AND ( - subq_32.metric_time__day IS NULL - ) - ) + subq_24.metric_time__day = subq_32.metric_time__day + GROUP BY + COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) ) subq_33 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index 480956ae99..e34bb8173a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) AS metric_time__year - , subq_7.month_start_bookings AS month_start_bookings - , subq_15.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_7.month_start_bookings) AS month_start_bookings + , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -325,7 +325,7 @@ FROM ( subq_5.metric_time__year ) subq_6 ) subq_7 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_14.metric_time__year @@ -642,13 +642,7 @@ FROM ( ) subq_14 ) subq_15 ON - ( - subq_7.metric_time__year = subq_15.metric_time__year - ) OR ( - ( - subq_7.metric_time__year IS NULL - ) AND ( - subq_15.metric_time__year IS NULL - ) - ) + subq_7.metric_time__year = subq_15.metric_time__year + GROUP BY + COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) ) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 40dd779220..f06da5a3a2 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) AS metric_time__year - , subq_24.month_start_bookings AS month_start_bookings - , subq_32.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_24.month_start_bookings) AS month_start_bookings + , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: @@ -32,7 +32,7 @@ FROM ( GROUP BY DATE_TRUNC('year', subq_20.ds) ) subq_24 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__year'] @@ -56,13 +56,7 @@ FROM ( DATE_TRUNC('year', subq_28.ds) ) subq_32 ON - ( - subq_24.metric_time__year = subq_32.metric_time__year - ) OR ( - ( - subq_24.metric_time__year IS NULL - ) AND ( - subq_32.metric_time__year IS NULL - ) - ) + subq_24.metric_time__year = subq_32.metric_time__year + GROUP BY + COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) ) subq_33 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0.sql index 03a508ea2b..a91d132652 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) AS metric_time__day - , subq_11.non_referred AS non_referred - , subq_16.instant AS instant - , subq_21.bookings AS bookings + , MAX(subq_11.non_referred) AS non_referred + , MAX(subq_16.instant) AS instant + , MAX(subq_21.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -18,8 +18,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , subq_4.ref_bookings AS ref_bookings - , subq_9.bookings AS bookings + , MAX(subq_4.ref_bookings) AS ref_bookings + , MAX(subq_9.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -236,7 +236,7 @@ FROM ( subq_2.metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_8.metric_time__day @@ -453,18 +453,12 @@ FROM ( ) subq_8 ) subq_9 ON - ( - subq_4.metric_time__day = subq_9.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_9.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_9.metric_time__day + GROUP BY + COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) ) subq_10 ) subq_11 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_15.metric_time__day @@ -681,16 +675,8 @@ FROM ( ) subq_15 ) subq_16 ON - ( - subq_11.metric_time__day = subq_16.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_16.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_11.metric_time__day = subq_16.metric_time__day + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_20.metric_time__day @@ -907,13 +893,7 @@ FROM ( ) subq_20 ) subq_21 ON - ( - subq_11.metric_time__day = subq_21.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_21.metric_time__day IS NULL - ) - ) + COALESCE(subq_11.metric_time__day, subq_16.metric_time__day) = subq_21.metric_time__day + GROUP BY + COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) ) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0_optimized.sql index 519c4b6ea5..86124d9091 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0_optimized.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) AS metric_time__day - , subq_34.non_referred AS non_referred - , subq_39.instant AS instant - , subq_44.bookings AS bookings + , MAX(subq_34.non_referred) AS non_referred + , MAX(subq_39.instant) AS instant + , MAX(subq_44.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -18,8 +18,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , subq_27.ref_bookings AS ref_bookings - , subq_32.bookings AS bookings + , MAX(subq_27.ref_bookings) AS ref_bookings + , MAX(subq_32.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -39,7 +39,7 @@ FROM ( GROUP BY metric_time__day ) subq_27 - INNER JOIN ( + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -59,18 +59,12 @@ FROM ( metric_time__day ) subq_32 ON - ( - subq_27.metric_time__day = subq_32.metric_time__day - ) OR ( - ( - subq_27.metric_time__day IS NULL - ) AND ( - subq_32.metric_time__day IS NULL - ) - ) + subq_27.metric_time__day = subq_32.metric_time__day + GROUP BY + COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) ) subq_33 ) subq_34 - INNER JOIN ( + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -90,16 +84,8 @@ FROM ( metric_time__day ) subq_39 ON - ( - subq_34.metric_time__day = subq_39.metric_time__day - ) OR ( - ( - subq_34.metric_time__day IS NULL - ) AND ( - subq_39.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_34.metric_time__day = subq_39.metric_time__day + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -119,13 +105,7 @@ FROM ( metric_time__day ) subq_44 ON - ( - subq_34.metric_time__day = subq_44.metric_time__day - ) OR ( - ( - subq_34.metric_time__day IS NULL - ) AND ( - subq_44.metric_time__day IS NULL - ) - ) + COALESCE(subq_34.metric_time__day, subq_39.metric_time__day) = subq_44.metric_time__day + GROUP BY + COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) ) subq_45 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0.sql index cb3a0a1cb5..210db4a0aa 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , subq_4.ref_bookings AS ref_bookings - , subq_9.bookings AS bookings + , MAX(subq_4.ref_bookings) AS ref_bookings + , MAX(subq_9.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_8.metric_time__day @@ -441,13 +441,7 @@ FROM ( ) subq_8 ) subq_9 ON - ( - subq_4.metric_time__day = subq_9.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_9.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_9.metric_time__day + GROUP BY + COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) ) subq_10 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0_optimized.sql index ace6863100..f7d37d45b3 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) AS metric_time__day - , subq_15.ref_bookings AS ref_bookings - , subq_20.bookings AS bookings + , MAX(subq_15.ref_bookings) AS ref_bookings + , MAX(subq_20.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__day ) subq_15 - INNER JOIN ( + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -47,13 +47,7 @@ FROM ( metric_time__day ) subq_20 ON - ( - subq_15.metric_time__day = subq_20.metric_time__day - ) OR ( - ( - subq_15.metric_time__day IS NULL - ) AND ( - subq_20.metric_time__day IS NULL - ) - ) + subq_15.metric_time__day = subq_20.metric_time__day + GROUP BY + COALESCE(subq_15.metric_time__day, subq_20.metric_time__day) ) subq_21 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql index cc265b93d5..35a7062093 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , subq_4.bookings AS bookings - , subq_12.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__day @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__day = subq_12.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_12.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_12.metric_time__day + GROUP BY + COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index a952516e96..6d1b17b416 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , subq_18.bookings AS bookings - , subq_26.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__day ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -51,13 +51,7 @@ FROM ( subq_22.ds ) subq_26 ON - ( - subq_18.metric_time__day = subq_26.metric_time__day - ) OR ( - ( - subq_18.metric_time__day IS NULL - ) AND ( - subq_26.metric_time__day IS NULL - ) - ) + subq_18.metric_time__day = subq_26.metric_time__day + GROUP BY + COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index 58273e79e0..56d35de19c 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) AS metric_time__week - , subq_4.bookings AS bookings - , subq_12.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__week ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__week @@ -542,13 +542,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__week = subq_12.metric_time__week - ) OR ( - ( - subq_4.metric_time__week IS NULL - ) AND ( - subq_12.metric_time__week IS NULL - ) - ) + subq_4.metric_time__week = subq_12.metric_time__week + GROUP BY + COALESCE(subq_4.metric_time__week, subq_12.metric_time__week) ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index e5a7e1789c..5b18fcfa5f 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) AS metric_time__week - , subq_18.bookings AS bookings - , subq_26.bookings_at_start_of_month AS bookings_at_start_of_month + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_at_start_of_month) AS bookings_at_start_of_month FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__week ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__week'] @@ -52,13 +52,7 @@ FROM ( DATE_TRUNC('week', subq_22.ds) ) subq_26 ON - ( - subq_18.metric_time__week = subq_26.metric_time__week - ) OR ( - ( - subq_18.metric_time__week IS NULL - ) AND ( - subq_26.metric_time__week IS NULL - ) - ) + subq_18.metric_time__week = subq_26.metric_time__week + GROUP BY + COALESCE(subq_18.metric_time__week, subq_26.metric_time__week) ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql index 9bb8261142..b79d2fadce 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , subq_4.bookings AS bookings - , subq_12.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__day @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__day = subq_12.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_12.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_12.metric_time__day + GROUP BY + COALESCE(subq_4.metric_time__day, subq_12.metric_time__day) ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0_optimized.sql index d79d809654..a01f18c65d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , subq_18.bookings AS bookings - , subq_26.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__day ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -51,13 +51,7 @@ FROM ( subq_22.ds ) subq_26 ON - ( - subq_18.metric_time__day = subq_26.metric_time__day - ) OR ( - ( - subq_18.metric_time__day IS NULL - ) AND ( - subq_26.metric_time__day IS NULL - ) - ) + subq_18.metric_time__day = subq_26.metric_time__day + GROUP BY + COALESCE(subq_18.metric_time__day, subq_26.metric_time__day) ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 383d66efb3..5e159a592a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) AS metric_time__quarter - , subq_4.bookings AS bookings - , subq_12.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__quarter ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__quarter @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__quarter = subq_12.metric_time__quarter - ) OR ( - ( - subq_4.metric_time__quarter IS NULL - ) AND ( - subq_12.metric_time__quarter IS NULL - ) - ) + subq_4.metric_time__quarter = subq_12.metric_time__quarter + GROUP BY + COALESCE(subq_4.metric_time__quarter, subq_12.metric_time__quarter) ) subq_13 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index bbdb2547b7..10ccf3e20b 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) AS metric_time__quarter - , subq_18.bookings AS bookings - , subq_26.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__quarter ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__quarter'] @@ -51,13 +51,7 @@ FROM ( DATE_TRUNC('quarter', subq_22.ds) ) subq_26 ON - ( - subq_18.metric_time__quarter = subq_26.metric_time__quarter - ) OR ( - ( - subq_18.metric_time__quarter IS NULL - ) AND ( - subq_26.metric_time__quarter IS NULL - ) - ) + subq_18.metric_time__quarter = subq_26.metric_time__quarter + GROUP BY + COALESCE(subq_18.metric_time__quarter, subq_26.metric_time__quarter) ) subq_27 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 35afabacce..d9b9bf4244 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , subq_7.month_start_bookings AS month_start_bookings - , subq_15.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_7.month_start_bookings) AS month_start_bookings + , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -324,7 +324,7 @@ FROM ( subq_5.metric_time__day ) subq_6 ) subq_7 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_14.metric_time__day @@ -641,13 +641,7 @@ FROM ( ) subq_14 ) subq_15 ON - ( - subq_7.metric_time__day = subq_15.metric_time__day - ) OR ( - ( - subq_7.metric_time__day IS NULL - ) AND ( - subq_15.metric_time__day IS NULL - ) - ) + subq_7.metric_time__day = subq_15.metric_time__day + GROUP BY + COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) ) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 3f57ba0cbf..91dc642b1b 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , subq_24.month_start_bookings AS month_start_bookings - , subq_32.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_24.month_start_bookings) AS month_start_bookings + , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: @@ -31,7 +31,7 @@ FROM ( GROUP BY subq_20.ds ) subq_24 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -55,13 +55,7 @@ FROM ( subq_28.ds ) subq_32 ON - ( - subq_24.metric_time__day = subq_32.metric_time__day - ) OR ( - ( - subq_24.metric_time__day IS NULL - ) AND ( - subq_32.metric_time__day IS NULL - ) - ) + subq_24.metric_time__day = subq_32.metric_time__day + GROUP BY + COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) ) subq_33 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index 2b4a562439..7416cc58f2 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) AS metric_time__year - , subq_7.month_start_bookings AS month_start_bookings - , subq_15.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_7.month_start_bookings) AS month_start_bookings + , MAX(subq_15.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -325,7 +325,7 @@ FROM ( subq_5.metric_time__year ) subq_6 ) subq_7 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_14.metric_time__year @@ -642,13 +642,7 @@ FROM ( ) subq_14 ) subq_15 ON - ( - subq_7.metric_time__year = subq_15.metric_time__year - ) OR ( - ( - subq_7.metric_time__year IS NULL - ) AND ( - subq_15.metric_time__year IS NULL - ) - ) + subq_7.metric_time__year = subq_15.metric_time__year + GROUP BY + COALESCE(subq_7.metric_time__year, subq_15.metric_time__year) ) subq_16 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 40dd779220..f06da5a3a2 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) AS metric_time__year - , subq_24.month_start_bookings AS month_start_bookings - , subq_32.bookings_1_month_ago AS bookings_1_month_ago + , MAX(subq_24.month_start_bookings) AS month_start_bookings + , MAX(subq_32.bookings_1_month_ago) AS bookings_1_month_ago FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: @@ -32,7 +32,7 @@ FROM ( GROUP BY DATE_TRUNC('year', subq_20.ds) ) subq_24 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__year'] @@ -56,13 +56,7 @@ FROM ( DATE_TRUNC('year', subq_28.ds) ) subq_32 ON - ( - subq_24.metric_time__year = subq_32.metric_time__year - ) OR ( - ( - subq_24.metric_time__year IS NULL - ) AND ( - subq_32.metric_time__year IS NULL - ) - ) + subq_24.metric_time__year = subq_32.metric_time__year + GROUP BY + COALESCE(subq_24.metric_time__year, subq_32.metric_time__year) ) subq_33 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0.sql index f3ab290f85..307275d7d4 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) AS metric_time__day - , subq_11.non_referred AS non_referred - , subq_16.instant AS instant - , subq_21.bookings AS bookings + , MAX(subq_11.non_referred) AS non_referred + , MAX(subq_16.instant) AS instant + , MAX(subq_21.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -18,8 +18,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) AS metric_time__day - , subq_4.ref_bookings AS ref_bookings - , subq_9.bookings AS bookings + , MAX(subq_4.ref_bookings) AS ref_bookings + , MAX(subq_9.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -236,7 +236,7 @@ FROM ( subq_2.metric_time__day ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_8.metric_time__day @@ -453,18 +453,12 @@ FROM ( ) subq_8 ) subq_9 ON - ( - subq_4.metric_time__day = subq_9.metric_time__day - ) OR ( - ( - subq_4.metric_time__day IS NULL - ) AND ( - subq_9.metric_time__day IS NULL - ) - ) + subq_4.metric_time__day = subq_9.metric_time__day + GROUP BY + COALESCE(subq_4.metric_time__day, subq_9.metric_time__day) ) subq_10 ) subq_11 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_15.metric_time__day @@ -681,16 +675,8 @@ FROM ( ) subq_15 ) subq_16 ON - ( - subq_11.metric_time__day = subq_16.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_16.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_11.metric_time__day = subq_16.metric_time__day + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_20.metric_time__day @@ -907,13 +893,7 @@ FROM ( ) subq_20 ) subq_21 ON - ( - subq_11.metric_time__day = subq_21.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_21.metric_time__day IS NULL - ) - ) + COALESCE(subq_11.metric_time__day, subq_16.metric_time__day) = subq_21.metric_time__day + GROUP BY + COALESCE(subq_11.metric_time__day, subq_16.metric_time__day, subq_21.metric_time__day) ) subq_22 diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0_optimized.sql index 519c4b6ea5..86124d9091 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0_optimized.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) AS metric_time__day - , subq_34.non_referred AS non_referred - , subq_39.instant AS instant - , subq_44.bookings AS bookings + , MAX(subq_34.non_referred) AS non_referred + , MAX(subq_39.instant) AS instant + , MAX(subq_44.bookings) AS bookings FROM ( -- Compute Metrics via Expressions SELECT @@ -18,8 +18,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , subq_27.ref_bookings AS ref_bookings - , subq_32.bookings AS bookings + , MAX(subq_27.ref_bookings) AS ref_bookings + , MAX(subq_32.bookings) AS bookings FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -39,7 +39,7 @@ FROM ( GROUP BY metric_time__day ) subq_27 - INNER JOIN ( + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -59,18 +59,12 @@ FROM ( metric_time__day ) subq_32 ON - ( - subq_27.metric_time__day = subq_32.metric_time__day - ) OR ( - ( - subq_27.metric_time__day IS NULL - ) AND ( - subq_32.metric_time__day IS NULL - ) - ) + subq_27.metric_time__day = subq_32.metric_time__day + GROUP BY + COALESCE(subq_27.metric_time__day, subq_32.metric_time__day) ) subq_33 ) subq_34 - INNER JOIN ( + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -90,16 +84,8 @@ FROM ( metric_time__day ) subq_39 ON - ( - subq_34.metric_time__day = subq_39.metric_time__day - ) OR ( - ( - subq_34.metric_time__day IS NULL - ) AND ( - subq_39.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_34.metric_time__day = subq_39.metric_time__day + FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT @@ -119,13 +105,7 @@ FROM ( metric_time__day ) subq_44 ON - ( - subq_34.metric_time__day = subq_44.metric_time__day - ) OR ( - ( - subq_34.metric_time__day IS NULL - ) AND ( - subq_44.metric_time__day IS NULL - ) - ) + COALESCE(subq_34.metric_time__day, subq_39.metric_time__day) = subq_44.metric_time__day + GROUP BY + COALESCE(subq_34.metric_time__day, subq_39.metric_time__day, subq_44.metric_time__day) ) subq_45 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0.sql index c4cee9ab44..241e16efe2 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , subq_7.bookings_fill_nulls_with_0 AS bookings_fill_nulls_with_0 - , subq_15.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_7.bookings_fill_nulls_with_0) AS bookings_fill_nulls_with_0 + , MAX(subq_15.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -238,7 +238,7 @@ FROM ( subq_4.metric_time__day = subq_3.metric_time__day ) subq_6 ) subq_7 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_14.metric_time__day @@ -555,13 +555,7 @@ FROM ( ) subq_14 ) subq_15 ON - ( - subq_7.metric_time__day = subq_15.metric_time__day - ) OR ( - ( - subq_7.metric_time__day IS NULL - ) AND ( - subq_15.metric_time__day IS NULL - ) - ) + subq_7.metric_time__day = subq_15.metric_time__day + GROUP BY + metric_time__day ) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index 5ffc1d5ae6..f2c1764b36 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , subq_24.bookings_fill_nulls_with_0 AS bookings_fill_nulls_with_0 - , subq_32.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_24.bookings_fill_nulls_with_0) AS bookings_fill_nulls_with_0 + , MAX(subq_32.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -41,7 +41,7 @@ FROM ( subq_22.ds = subq_20.metric_time__day ) subq_23 ) subq_24 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -65,13 +65,7 @@ FROM ( metric_time__day ) subq_32 ON - ( - subq_24.metric_time__day = subq_32.metric_time__day - ) OR ( - ( - subq_24.metric_time__day IS NULL - ) AND ( - subq_32.metric_time__day IS NULL - ) - ) + subq_24.metric_time__day = subq_32.metric_time__day + GROUP BY + metric_time__day ) subq_33 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 799b015746..d107d58633 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , subq_7.bookings_fill_nulls_with_0 AS bookings_fill_nulls_with_0 - , subq_15.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_7.bookings_fill_nulls_with_0) AS bookings_fill_nulls_with_0 + , MAX(subq_15.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -238,7 +238,7 @@ FROM ( subq_4.metric_time__day = subq_3.metric_time__day ) subq_6 ) subq_7 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_14.metric_time__day @@ -555,13 +555,7 @@ FROM ( ) subq_14 ) subq_15 ON - ( - subq_7.metric_time__day = subq_15.metric_time__day - ) OR ( - ( - subq_7.metric_time__day IS NULL - ) AND ( - subq_15.metric_time__day IS NULL - ) - ) + subq_7.metric_time__day = subq_15.metric_time__day + GROUP BY + COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) ) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index aeeadbbc85..ca26d38ede 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , subq_24.bookings_fill_nulls_with_0 AS bookings_fill_nulls_with_0 - , subq_32.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_24.bookings_fill_nulls_with_0) AS bookings_fill_nulls_with_0 + , MAX(subq_32.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -41,7 +41,7 @@ FROM ( subq_22.ds = subq_20.metric_time__day ) subq_23 ) subq_24 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -65,13 +65,7 @@ FROM ( subq_28.ds ) subq_32 ON - ( - subq_24.metric_time__day = subq_32.metric_time__day - ) OR ( - ( - subq_24.metric_time__day IS NULL - ) AND ( - subq_32.metric_time__day IS NULL - ) - ) + subq_24.metric_time__day = subq_32.metric_time__day + GROUP BY + COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) ) subq_33 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 77e93edc2e..8c871556dc 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , subq_7.bookings_fill_nulls_with_0 AS bookings_fill_nulls_with_0 - , subq_15.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_7.bookings_fill_nulls_with_0) AS bookings_fill_nulls_with_0 + , MAX(subq_15.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -238,7 +238,7 @@ FROM ( subq_4.metric_time__day = subq_3.metric_time__day ) subq_6 ) subq_7 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_14.metric_time__day @@ -555,13 +555,7 @@ FROM ( ) subq_14 ) subq_15 ON - ( - subq_7.metric_time__day = subq_15.metric_time__day - ) OR ( - ( - subq_7.metric_time__day IS NULL - ) AND ( - subq_15.metric_time__day IS NULL - ) - ) + subq_7.metric_time__day = subq_15.metric_time__day + GROUP BY + COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) ) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index 4c7957c237..d8cf4d63f9 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , subq_24.bookings_fill_nulls_with_0 AS bookings_fill_nulls_with_0 - , subq_32.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_24.bookings_fill_nulls_with_0) AS bookings_fill_nulls_with_0 + , MAX(subq_32.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -41,7 +41,7 @@ FROM ( subq_22.ds = subq_20.metric_time__day ) subq_23 ) subq_24 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -65,13 +65,7 @@ FROM ( subq_28.ds ) subq_32 ON - ( - subq_24.metric_time__day = subq_32.metric_time__day - ) OR ( - ( - subq_24.metric_time__day IS NULL - ) AND ( - subq_32.metric_time__day IS NULL - ) - ) + subq_24.metric_time__day = subq_32.metric_time__day + GROUP BY + COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) ) subq_33 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 60a3863492..f6f0f67739 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , subq_7.bookings_fill_nulls_with_0 AS bookings_fill_nulls_with_0 - , subq_15.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_7.bookings_fill_nulls_with_0) AS bookings_fill_nulls_with_0 + , MAX(subq_15.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -238,7 +238,7 @@ FROM ( subq_4.metric_time__day = subq_3.metric_time__day ) subq_6 ) subq_7 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_14.metric_time__day @@ -555,13 +555,7 @@ FROM ( ) subq_14 ) subq_15 ON - ( - subq_7.metric_time__day = subq_15.metric_time__day - ) OR ( - ( - subq_7.metric_time__day IS NULL - ) AND ( - subq_15.metric_time__day IS NULL - ) - ) + subq_7.metric_time__day = subq_15.metric_time__day + GROUP BY + COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) ) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index aeeadbbc85..ca26d38ede 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , subq_24.bookings_fill_nulls_with_0 AS bookings_fill_nulls_with_0 - , subq_32.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_24.bookings_fill_nulls_with_0) AS bookings_fill_nulls_with_0 + , MAX(subq_32.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -41,7 +41,7 @@ FROM ( subq_22.ds = subq_20.metric_time__day ) subq_23 ) subq_24 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -65,13 +65,7 @@ FROM ( subq_28.ds ) subq_32 ON - ( - subq_24.metric_time__day = subq_32.metric_time__day - ) OR ( - ( - subq_24.metric_time__day IS NULL - ) AND ( - subq_32.metric_time__day IS NULL - ) - ) + subq_24.metric_time__day = subq_32.metric_time__day + GROUP BY + COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) ) subq_33 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 8d8e4dfed0..4193003958 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) AS metric_time__day - , subq_7.bookings_fill_nulls_with_0 AS bookings_fill_nulls_with_0 - , subq_15.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_7.bookings_fill_nulls_with_0) AS bookings_fill_nulls_with_0 + , MAX(subq_15.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -238,7 +238,7 @@ FROM ( subq_4.metric_time__day = subq_3.metric_time__day ) subq_6 ) subq_7 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_14.metric_time__day @@ -555,13 +555,7 @@ FROM ( ) subq_14 ) subq_15 ON - ( - subq_7.metric_time__day = subq_15.metric_time__day - ) OR ( - ( - subq_7.metric_time__day IS NULL - ) AND ( - subq_15.metric_time__day IS NULL - ) - ) + subq_7.metric_time__day = subq_15.metric_time__day + GROUP BY + COALESCE(subq_7.metric_time__day, subq_15.metric_time__day) ) subq_16 diff --git a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index aeeadbbc85..ca26d38ede 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) AS metric_time__day - , subq_24.bookings_fill_nulls_with_0 AS bookings_fill_nulls_with_0 - , subq_32.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_24.bookings_fill_nulls_with_0) AS bookings_fill_nulls_with_0 + , MAX(subq_32.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -41,7 +41,7 @@ FROM ( subq_22.ds = subq_20.metric_time__day ) subq_23 ) subq_24 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -65,13 +65,7 @@ FROM ( subq_28.ds ) subq_32 ON - ( - subq_24.metric_time__day = subq_32.metric_time__day - ) OR ( - ( - subq_24.metric_time__day IS NULL - ) AND ( - subq_32.metric_time__day IS NULL - ) - ) + subq_24.metric_time__day = subq_32.metric_time__day + GROUP BY + COALESCE(subq_24.metric_time__day, subq_32.metric_time__day) ) subq_33 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0.sql index 6ea84b81d5..4a09d351d9 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) AS metric_time__extract_dow - , subq_4.bookings AS bookings - , subq_12.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( metric_time__extract_dow ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__extract_dow @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__extract_dow = subq_12.metric_time__extract_dow - ) OR ( - ( - subq_4.metric_time__extract_dow IS NULL - ) AND ( - subq_12.metric_time__extract_dow IS NULL - ) - ) + subq_4.metric_time__extract_dow = subq_12.metric_time__extract_dow + GROUP BY + metric_time__extract_dow ) subq_13 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0_optimized.sql index f598ede944..1750a456ed 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) AS metric_time__extract_dow - , subq_18.bookings AS bookings - , subq_26.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__extract_dow ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__extract_dow'] @@ -51,13 +51,7 @@ FROM ( metric_time__extract_dow ) subq_26 ON - ( - subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow - ) OR ( - ( - subq_18.metric_time__extract_dow IS NULL - ) AND ( - subq_26.metric_time__extract_dow IS NULL - ) - ) + subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow + GROUP BY + metric_time__extract_dow ) subq_27 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0.sql index 2879967246..ff637a4a8f 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) AS metric_time__extract_dow - , subq_4.bookings AS bookings - , subq_12.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__extract_dow ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__extract_dow @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__extract_dow = subq_12.metric_time__extract_dow - ) OR ( - ( - subq_4.metric_time__extract_dow IS NULL - ) AND ( - subq_12.metric_time__extract_dow IS NULL - ) - ) + subq_4.metric_time__extract_dow = subq_12.metric_time__extract_dow + GROUP BY + COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) ) subq_13 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0_optimized.sql index bc01ce93a7..47d65c62a5 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) AS metric_time__extract_dow - , subq_18.bookings AS bookings - , subq_26.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__extract_dow ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__extract_dow'] @@ -51,13 +51,7 @@ FROM ( EXTRACT(DAYOFWEEK_ISO FROM subq_22.ds) ) subq_26 ON - ( - subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow - ) OR ( - ( - subq_18.metric_time__extract_dow IS NULL - ) AND ( - subq_26.metric_time__extract_dow IS NULL - ) - ) + subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow + GROUP BY + COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) ) subq_27 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0.sql index aaa751eac2..5bb0010ee6 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) AS metric_time__extract_dow - , subq_4.bookings AS bookings - , subq_12.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__extract_dow ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__extract_dow @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__extract_dow = subq_12.metric_time__extract_dow - ) OR ( - ( - subq_4.metric_time__extract_dow IS NULL - ) AND ( - subq_12.metric_time__extract_dow IS NULL - ) - ) + subq_4.metric_time__extract_dow = subq_12.metric_time__extract_dow + GROUP BY + COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) ) subq_13 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0_optimized.sql index 5bded3a842..b40bc359ae 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) AS metric_time__extract_dow - , subq_18.bookings AS bookings - , subq_26.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__extract_dow ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__extract_dow'] @@ -51,13 +51,7 @@ FROM ( EXTRACT(isodow FROM subq_22.ds) ) subq_26 ON - ( - subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow - ) OR ( - ( - subq_18.metric_time__extract_dow IS NULL - ) AND ( - subq_26.metric_time__extract_dow IS NULL - ) - ) + subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow + GROUP BY + COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) ) subq_27 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0.sql index 54705a6623..3634349b84 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) AS metric_time__extract_dow - , subq_4.bookings AS bookings - , subq_12.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__extract_dow ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__extract_dow @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__extract_dow = subq_12.metric_time__extract_dow - ) OR ( - ( - subq_4.metric_time__extract_dow IS NULL - ) AND ( - subq_12.metric_time__extract_dow IS NULL - ) - ) + subq_4.metric_time__extract_dow = subq_12.metric_time__extract_dow + GROUP BY + COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) ) subq_13 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0_optimized.sql index b13ff4875e..d544c6c2a2 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) AS metric_time__extract_dow - , subq_18.bookings AS bookings - , subq_26.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__extract_dow ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__extract_dow'] @@ -51,13 +51,7 @@ FROM ( CASE WHEN EXTRACT(dow FROM subq_22.ds) = 0 THEN EXTRACT(dow FROM subq_22.ds) + 7 ELSE EXTRACT(dow FROM subq_22.ds) END ) subq_26 ON - ( - subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow - ) OR ( - ( - subq_18.metric_time__extract_dow IS NULL - ) AND ( - subq_26.metric_time__extract_dow IS NULL - ) - ) + subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow + GROUP BY + COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) ) subq_27 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0.sql index 6d7c068e2a..4cd16e6523 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) AS metric_time__extract_dow - , subq_4.bookings AS bookings - , subq_12.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_4.bookings) AS bookings + , MAX(subq_12.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Compute Metrics via Expressions SELECT @@ -224,7 +224,7 @@ FROM ( subq_2.metric_time__extract_dow ) subq_3 ) subq_4 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_11.metric_time__extract_dow @@ -541,13 +541,7 @@ FROM ( ) subq_11 ) subq_12 ON - ( - subq_4.metric_time__extract_dow = subq_12.metric_time__extract_dow - ) OR ( - ( - subq_4.metric_time__extract_dow IS NULL - ) AND ( - subq_12.metric_time__extract_dow IS NULL - ) - ) + subq_4.metric_time__extract_dow = subq_12.metric_time__extract_dow + GROUP BY + COALESCE(subq_4.metric_time__extract_dow, subq_12.metric_time__extract_dow) ) subq_13 diff --git a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0_optimized.sql index 253be04861..9daf56bc90 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0_optimized.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) AS metric_time__extract_dow - , subq_18.bookings AS bookings - , subq_26.bookings_2_weeks_ago AS bookings_2_weeks_ago + , MAX(subq_18.bookings) AS bookings + , MAX(subq_26.bookings_2_weeks_ago) AS bookings_2_weeks_ago FROM ( -- Aggregate Measures -- Compute Metrics via Expressions @@ -27,7 +27,7 @@ FROM ( GROUP BY metric_time__extract_dow ) subq_18 - INNER JOIN ( + FULL OUTER JOIN ( -- Join to Time Spine Dataset -- Pass Only Elements: -- ['bookings', 'metric_time__extract_dow'] @@ -51,13 +51,7 @@ FROM ( EXTRACT(dayofweekiso FROM subq_22.ds) ) subq_26 ON - ( - subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow - ) OR ( - ( - subq_18.metric_time__extract_dow IS NULL - ) AND ( - subq_26.metric_time__extract_dow IS NULL - ) - ) + subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow + GROUP BY + COALESCE(subq_18.metric_time__extract_dow, subq_26.metric_time__extract_dow) ) subq_27 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql index 39b8a67764..4c176465fe 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , subq_11.average_booking_value AS average_booking_value - , subq_23.bookings AS bookings - , subq_28.booking_value AS booking_value + , MAX(subq_11.average_booking_value) AS average_booking_value + , MAX(subq_23.bookings) AS bookings + , MAX(subq_28.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT @@ -398,7 +398,7 @@ FROM ( metric_time__day ) subq_10 ) subq_11 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_22.metric_time__day @@ -788,16 +788,8 @@ FROM ( ) subq_22 ) subq_23 ON - ( - subq_11.metric_time__day = subq_23.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_23.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_11.metric_time__day = subq_23.metric_time__day + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_27.metric_time__day @@ -1014,13 +1006,7 @@ FROM ( ) subq_27 ) subq_28 ON - ( - subq_11.metric_time__day = subq_28.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_28.metric_time__day IS NULL - ) - ) + COALESCE(subq_11.metric_time__day, subq_23.metric_time__day) = subq_28.metric_time__day + GROUP BY + metric_time__day ) subq_29 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0_optimized.sql index e3a2f21877..7449730839 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0_optimized.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) AS metric_time__day - , subq_41.average_booking_value AS average_booking_value - , subq_53.bookings AS bookings - , subq_58.booking_value AS booking_value + , MAX(subq_41.average_booking_value) AS average_booking_value + , MAX(subq_53.bookings) AS bookings + , MAX(subq_58.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: @@ -36,7 +36,7 @@ FROM ( GROUP BY metric_time__day ) subq_41 - INNER JOIN ( + FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -74,16 +74,8 @@ FROM ( metric_time__day ) subq_53 ON - ( - subq_41.metric_time__day = subq_53.metric_time__day - ) OR ( - ( - subq_41.metric_time__day IS NULL - ) AND ( - subq_53.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_41.metric_time__day = subq_53.metric_time__day + FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' -- Pass Only Elements: @@ -98,13 +90,7 @@ FROM ( metric_time__day ) subq_58 ON - ( - subq_41.metric_time__day = subq_58.metric_time__day - ) OR ( - ( - subq_41.metric_time__day IS NULL - ) AND ( - subq_58.metric_time__day IS NULL - ) - ) + COALESCE(subq_41.metric_time__day, subq_53.metric_time__day) = subq_58.metric_time__day + GROUP BY + metric_time__day ) subq_59 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql index 9bf98d60f7..21cf8ec5e7 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , subq_11.average_booking_value AS average_booking_value - , subq_23.bookings AS bookings - , subq_28.booking_value AS booking_value + , MAX(subq_11.average_booking_value) AS average_booking_value + , MAX(subq_23.bookings) AS bookings + , MAX(subq_28.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT @@ -398,7 +398,7 @@ FROM ( subq_9.metric_time__day ) subq_10 ) subq_11 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_22.metric_time__day @@ -788,16 +788,8 @@ FROM ( ) subq_22 ) subq_23 ON - ( - subq_11.metric_time__day = subq_23.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_23.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_11.metric_time__day = subq_23.metric_time__day + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_27.metric_time__day @@ -1014,13 +1006,7 @@ FROM ( ) subq_27 ) subq_28 ON - ( - subq_11.metric_time__day = subq_28.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_28.metric_time__day IS NULL - ) - ) + COALESCE(subq_11.metric_time__day, subq_23.metric_time__day) = subq_28.metric_time__day + GROUP BY + COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) ) subq_29 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0_optimized.sql index bf23abb3af..0b555b1430 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0_optimized.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) AS metric_time__day - , subq_41.average_booking_value AS average_booking_value - , subq_53.bookings AS bookings - , subq_58.booking_value AS booking_value + , MAX(subq_41.average_booking_value) AS average_booking_value + , MAX(subq_53.bookings) AS bookings + , MAX(subq_58.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: @@ -36,7 +36,7 @@ FROM ( GROUP BY metric_time__day ) subq_41 - INNER JOIN ( + FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -74,16 +74,8 @@ FROM ( metric_time__day ) subq_53 ON - ( - subq_41.metric_time__day = subq_53.metric_time__day - ) OR ( - ( - subq_41.metric_time__day IS NULL - ) AND ( - subq_53.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_41.metric_time__day = subq_53.metric_time__day + FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' -- Pass Only Elements: @@ -98,13 +90,7 @@ FROM ( DATE_TRUNC('day', ds) ) subq_58 ON - ( - subq_41.metric_time__day = subq_58.metric_time__day - ) OR ( - ( - subq_41.metric_time__day IS NULL - ) AND ( - subq_58.metric_time__day IS NULL - ) - ) + COALESCE(subq_41.metric_time__day, subq_53.metric_time__day) = subq_58.metric_time__day + GROUP BY + COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) ) subq_59 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql index dbb29c4d73..ba7e10edd2 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , subq_11.average_booking_value AS average_booking_value - , subq_23.bookings AS bookings - , subq_28.booking_value AS booking_value + , MAX(subq_11.average_booking_value) AS average_booking_value + , MAX(subq_23.bookings) AS bookings + , MAX(subq_28.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT @@ -398,7 +398,7 @@ FROM ( subq_9.metric_time__day ) subq_10 ) subq_11 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_22.metric_time__day @@ -788,16 +788,8 @@ FROM ( ) subq_22 ) subq_23 ON - ( - subq_11.metric_time__day = subq_23.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_23.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_11.metric_time__day = subq_23.metric_time__day + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_27.metric_time__day @@ -1014,13 +1006,7 @@ FROM ( ) subq_27 ) subq_28 ON - ( - subq_11.metric_time__day = subq_28.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_28.metric_time__day IS NULL - ) - ) + COALESCE(subq_11.metric_time__day, subq_23.metric_time__day) = subq_28.metric_time__day + GROUP BY + COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) ) subq_29 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0_optimized.sql index bf23abb3af..0b555b1430 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0_optimized.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) AS metric_time__day - , subq_41.average_booking_value AS average_booking_value - , subq_53.bookings AS bookings - , subq_58.booking_value AS booking_value + , MAX(subq_41.average_booking_value) AS average_booking_value + , MAX(subq_53.bookings) AS bookings + , MAX(subq_58.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: @@ -36,7 +36,7 @@ FROM ( GROUP BY metric_time__day ) subq_41 - INNER JOIN ( + FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -74,16 +74,8 @@ FROM ( metric_time__day ) subq_53 ON - ( - subq_41.metric_time__day = subq_53.metric_time__day - ) OR ( - ( - subq_41.metric_time__day IS NULL - ) AND ( - subq_53.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_41.metric_time__day = subq_53.metric_time__day + FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' -- Pass Only Elements: @@ -98,13 +90,7 @@ FROM ( DATE_TRUNC('day', ds) ) subq_58 ON - ( - subq_41.metric_time__day = subq_58.metric_time__day - ) OR ( - ( - subq_41.metric_time__day IS NULL - ) AND ( - subq_58.metric_time__day IS NULL - ) - ) + COALESCE(subq_41.metric_time__day, subq_53.metric_time__day) = subq_58.metric_time__day + GROUP BY + COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) ) subq_59 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql index 3a5a6abf29..53fc864739 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , subq_11.average_booking_value AS average_booking_value - , subq_23.bookings AS bookings - , subq_28.booking_value AS booking_value + , MAX(subq_11.average_booking_value) AS average_booking_value + , MAX(subq_23.bookings) AS bookings + , MAX(subq_28.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT @@ -398,7 +398,7 @@ FROM ( subq_9.metric_time__day ) subq_10 ) subq_11 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_22.metric_time__day @@ -788,16 +788,8 @@ FROM ( ) subq_22 ) subq_23 ON - ( - subq_11.metric_time__day = subq_23.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_23.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_11.metric_time__day = subq_23.metric_time__day + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_27.metric_time__day @@ -1014,13 +1006,7 @@ FROM ( ) subq_27 ) subq_28 ON - ( - subq_11.metric_time__day = subq_28.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_28.metric_time__day IS NULL - ) - ) + COALESCE(subq_11.metric_time__day, subq_23.metric_time__day) = subq_28.metric_time__day + GROUP BY + COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) ) subq_29 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0_optimized.sql index bf23abb3af..0b555b1430 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0_optimized.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) AS metric_time__day - , subq_41.average_booking_value AS average_booking_value - , subq_53.bookings AS bookings - , subq_58.booking_value AS booking_value + , MAX(subq_41.average_booking_value) AS average_booking_value + , MAX(subq_53.bookings) AS bookings + , MAX(subq_58.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: @@ -36,7 +36,7 @@ FROM ( GROUP BY metric_time__day ) subq_41 - INNER JOIN ( + FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -74,16 +74,8 @@ FROM ( metric_time__day ) subq_53 ON - ( - subq_41.metric_time__day = subq_53.metric_time__day - ) OR ( - ( - subq_41.metric_time__day IS NULL - ) AND ( - subq_53.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_41.metric_time__day = subq_53.metric_time__day + FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' -- Pass Only Elements: @@ -98,13 +90,7 @@ FROM ( DATE_TRUNC('day', ds) ) subq_58 ON - ( - subq_41.metric_time__day = subq_58.metric_time__day - ) OR ( - ( - subq_41.metric_time__day IS NULL - ) AND ( - subq_58.metric_time__day IS NULL - ) - ) + COALESCE(subq_41.metric_time__day, subq_53.metric_time__day) = subq_58.metric_time__day + GROUP BY + COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) ) subq_59 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql index 37506b49a2..d5276887ae 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) AS metric_time__day - , subq_11.average_booking_value AS average_booking_value - , subq_23.bookings AS bookings - , subq_28.booking_value AS booking_value + , MAX(subq_11.average_booking_value) AS average_booking_value + , MAX(subq_23.bookings) AS bookings + , MAX(subq_28.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT @@ -398,7 +398,7 @@ FROM ( subq_9.metric_time__day ) subq_10 ) subq_11 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_22.metric_time__day @@ -788,16 +788,8 @@ FROM ( ) subq_22 ) subq_23 ON - ( - subq_11.metric_time__day = subq_23.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_23.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_11.metric_time__day = subq_23.metric_time__day + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_27.metric_time__day @@ -1014,13 +1006,7 @@ FROM ( ) subq_27 ) subq_28 ON - ( - subq_11.metric_time__day = subq_28.metric_time__day - ) OR ( - ( - subq_11.metric_time__day IS NULL - ) AND ( - subq_28.metric_time__day IS NULL - ) - ) + COALESCE(subq_11.metric_time__day, subq_23.metric_time__day) = subq_28.metric_time__day + GROUP BY + COALESCE(subq_11.metric_time__day, subq_23.metric_time__day, subq_28.metric_time__day) ) subq_29 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0_optimized.sql index bf23abb3af..0b555b1430 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0_optimized.sql @@ -6,9 +6,9 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) AS metric_time__day - , subq_41.average_booking_value AS average_booking_value - , subq_53.bookings AS bookings - , subq_58.booking_value AS booking_value + , MAX(subq_41.average_booking_value) AS average_booking_value + , MAX(subq_53.bookings) AS bookings + , MAX(subq_58.booking_value) AS booking_value FROM ( -- Constrain Output with WHERE -- Pass Only Elements: @@ -36,7 +36,7 @@ FROM ( GROUP BY metric_time__day ) subq_41 - INNER JOIN ( + FULL OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: -- ['bookings', 'metric_time__day'] @@ -74,16 +74,8 @@ FROM ( metric_time__day ) subq_53 ON - ( - subq_41.metric_time__day = subq_53.metric_time__day - ) OR ( - ( - subq_41.metric_time__day IS NULL - ) AND ( - subq_53.metric_time__day IS NULL - ) - ) - INNER JOIN ( + subq_41.metric_time__day = subq_53.metric_time__day + FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' -- Pass Only Elements: @@ -98,13 +90,7 @@ FROM ( DATE_TRUNC('day', ds) ) subq_58 ON - ( - subq_41.metric_time__day = subq_58.metric_time__day - ) OR ( - ( - subq_41.metric_time__day IS NULL - ) AND ( - subq_58.metric_time__day IS NULL - ) - ) + COALESCE(subq_41.metric_time__day, subq_53.metric_time__day) = subq_58.metric_time__day + GROUP BY + COALESCE(subq_41.metric_time__day, subq_53.metric_time__day, subq_58.metric_time__day) ) subq_59