From e0cb00f79b7a3b5d53b0c8b952e397bc89b5407e Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Fri, 3 Nov 2023 11:16:52 -0700 Subject: [PATCH 1/8] Switch to OUTER JOIN for derived metrics --- metricflow/dataflow/builder/dataflow_plan_builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metricflow/dataflow/builder/dataflow_plan_builder.py b/metricflow/dataflow/builder/dataflow_plan_builder.py index 32634cb0c5..77aaf112cf 100644 --- a/metricflow/dataflow/builder/dataflow_plan_builder.py +++ b/metricflow/dataflow/builder/dataflow_plan_builder.py @@ -248,7 +248,7 @@ def _build_metrics_output_node( queried_linkable_specs=queried_linkable_specs, where_constraint=where_constraint, time_range_constraint=time_range_constraint, - combine_metrics_join_type=SqlJoinType.INNER, + combine_metrics_join_type=SqlJoinType.FULL_OUTER if MetricType.DERIVED else SqlJoinType.INNER, ), metric_specs=[metric_spec], ) From fab0350f46e92a6c2abbc82512220a837d2e1c48 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Fri, 3 Nov 2023 11:18:08 -0700 Subject: [PATCH 2/8] Changelog --- .changes/unreleased/Breaking Changes-20231102-182815.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/Breaking Changes-20231102-182815.yaml diff --git a/.changes/unreleased/Breaking Changes-20231102-182815.yaml b/.changes/unreleased/Breaking Changes-20231102-182815.yaml new file mode 100644 index 0000000000..c4847a91c6 --- /dev/null +++ b/.changes/unreleased/Breaking Changes-20231102-182815.yaml @@ -0,0 +1,6 @@ +kind: Breaking Changes +body: Use FULL OUTER JOIN to combine input metrics for derived metrics. This is a change from using INNER JOIN and may result in changes in output. +time: 2023-11-02T18:28:15.181064-07:00 +custom: + Author: courtneyholcomb + Issue: "842" From 7aa46829cea166c60a7e08a0d6deae2951548388 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Fri, 3 Nov 2023 11:48:35 -0700 Subject: [PATCH 3/8] Update snapshots & test SQL --- .../dataflow/builder/dataflow_plan_builder.py | 4 +- .../integration/test_cases/itest_metrics.yaml | 28 +++++------ ..._derived_metric_offset_to_grain__dfp_0.xml | 3 +- ...in_to_time_spine_derived_metric__dfp_0.xml | 3 +- .../test_measure_constraint_plan__dfp_0.xml | 3 +- .../DuckDB/test_derived_metric__plan0.sql | 18 +++---- .../test_derived_metric__plan0_optimized.sql | 18 +++---- ...ved_metric_with_offset_to_grain__plan0.sql | 18 +++---- ..._with_offset_to_grain__plan0_optimized.sql | 18 +++---- ...offset_to_grain_and_granularity__plan0.sql | 18 +++---- ...grain_and_granularity__plan0_optimized.sql | 18 +++---- ...rived_metric_with_offset_window__plan0.sql | 18 +++---- ...ic_with_offset_window__plan0_optimized.sql | 18 +++---- ...h_offset_window_and_granularity__plan0.sql | 18 +++---- ...indow_and_granularity__plan0_optimized.sql | 18 +++---- ...fset_window_and_offset_to_grain__plan0.sql | 18 +++---- ...w_and_offset_to_grain__plan0_optimized.sql | 18 +++---- ...offset_to_grain_and_granularity__plan0.sql | 18 +++---- ...grain_and_granularity__plan0_optimized.sql | 18 +++---- .../test_nested_derived_metric__plan0.sql | 50 ++++++------------- ...nested_derived_metric__plan0_optimized.sql | 50 ++++++------------- ...fill_nulls_for_one_input_metric__plan0.sql | 18 +++---- ..._for_one_input_metric__plan0_optimized.sql | 18 +++---- ...st_offset_window_with_date_part__plan0.sql | 18 +++---- ...window_with_date_part__plan0_optimized.sql | 18 +++---- .../DuckDB/test_measure_constraint__plan0.sql | 32 ++++-------- ...st_measure_constraint__plan0_optimized.sql | 32 ++++-------- .../test_derived_metric__dfp_0.xml | 3 +- ..._metric_with_non_derived_metric__dfp_0.xml | 3 +- .../test_nested_derived_metric__dfp_0.xml | 6 ++- .../test_nested_derived_metric__dfpo_0.xml | 3 +- 31 files changed, 188 insertions(+), 356 deletions(-) diff --git a/metricflow/dataflow/builder/dataflow_plan_builder.py b/metricflow/dataflow/builder/dataflow_plan_builder.py index 77aaf112cf..650408bbe8 100644 --- a/metricflow/dataflow/builder/dataflow_plan_builder.py +++ b/metricflow/dataflow/builder/dataflow_plan_builder.py @@ -241,14 +241,14 @@ def _build_metrics_output_node( f"For {metric.type} metric: {metric_spec}, needed metrics are:\n" f"{pformat_big_objects(metric_input_specs=metric_input_specs)}" ) - + join_type = SqlJoinType.FULL_OUTER if metric.type is MetricType.DERIVED else SqlJoinType.INNER compute_metrics_node = ComputeMetricsNode( parent_node=self._build_metrics_output_node( metric_specs=metric_input_specs, queried_linkable_specs=queried_linkable_specs, where_constraint=where_constraint, time_range_constraint=time_range_constraint, - combine_metrics_join_type=SqlJoinType.FULL_OUTER if MetricType.DERIVED else SqlJoinType.INNER, + combine_metrics_join_type=join_type, ), metric_specs=[metric_spec], ) diff --git a/metricflow/test/integration/test_cases/itest_metrics.yaml b/metricflow/test/integration/test_cases/itest_metrics.yaml index ff3a87a121..1ae004a3bb 100644 --- a/metricflow/test/integration/test_cases/itest_metrics.yaml +++ b/metricflow/test/integration/test_cases/itest_metrics.yaml @@ -42,7 +42,7 @@ integration_test: FROM {{source_schema}}.fct_bookings GROUP BY ds ) b - JOIN ( + FULL OUTER JOIN ( SELECT SUM(1) AS views , ds @@ -519,7 +519,7 @@ integration_test: GROUP BY ds ) a - INNER JOIN ( + FULL OUTER JOIN ( SELECT SUM(1) AS lux_listings , created_at AS metric_time__day @@ -654,7 +654,7 @@ integration_test: ON a.listing_id = b.listing_id GROUP BY 2 ) bk - INNER JOIN ( + FULL OUTER JOIN ( SELECT SUM(1) AS views ,d.is_lux @@ -683,7 +683,7 @@ integration_test: GROUP BY metric_time__day ) a - INNER JOIN ( + FULL OUTER JOIN ( SELECT c.ds AS metric_time__day , d.bookings_2_weeks_ago AS bookings_2_weeks_ago @@ -718,7 +718,7 @@ integration_test: GROUP BY metric_time__day ) a - INNER JOIN ( + FULL OUTER JOIN ( SELECT c.ds AS metric_time__day , d.bookings_at_start_of_month AS bookings_at_start_of_month @@ -760,7 +760,7 @@ integration_test: ) f ON {{ render_date_sub("g", "ds", 1, TimeGranularity.MONTH) }} = f.metric_time__day ) a - INNER JOIN ( + FULL OUTER JOIN ( SELECT c.ds AS metric_time__day , d.bookings AS month_start_bookings @@ -808,7 +808,7 @@ integration_test: check_query: | SELECT booking_value - instant_booking_value AS booking_value_sub_instant - , a.metric_time__day + , COALESCE(a.metric_time__day, b.metric_time__day) AS metric_time__day FROM ( SELECT SUM(booking_value) AS instant_booking_value @@ -818,7 +818,7 @@ integration_test: GROUP BY ds ) a - INNER JOIN ( + FULL OUTER JOIN ( SELECT SUM(booking_value) AS booking_value , ds AS metric_time__day @@ -843,7 +843,7 @@ integration_test: FROM ( SELECT booking_value - instant_booking_value AS booking_value_sub_instant - , a.metric_time__day AS metric_time__day + , COALESCE(a.metric_time__day, b.metric_time__day) AS metric_time__day FROM ( SELECT SUM(booking_value) AS instant_booking_value @@ -853,7 +853,7 @@ integration_test: GROUP BY ds ) a - INNER JOIN ( + FULL OUTER JOIN ( SELECT SUM(booking_value) AS booking_value , ds AS metric_time__day @@ -901,7 +901,7 @@ integration_test: FROM {{ source_schema }}.fct_bookings GROUP BY metric_time__week ) a - INNER JOIN ( + FULL OUTER JOIN ( SELECT {{ render_date_trunc("c.ds", TimeGranularity.WEEK) }} AS metric_time__week , SUM(d.bookings_at_start_of_month) AS bookings_at_start_of_month @@ -944,7 +944,7 @@ integration_test: ON {{ render_date_sub("g", "ds", 1, TimeGranularity.MONTH) }} = f.metric_time__day GROUP BY metric_time__year ) a - INNER JOIN ( + FULL OUTER JOIN ( SELECT {{ render_date_trunc("c.ds", TimeGranularity.YEAR) }} AS metric_time__year , SUM(d.bookings) AS month_start_bookings @@ -1024,7 +1024,7 @@ integration_test: FROM {{ source_schema }}.fct_bookings GROUP BY metric_time__week, metric_time__month ) a - INNER JOIN ( + FULL OUTER JOIN ( SELECT {{ render_date_trunc("c.ds", TimeGranularity.WEEK) }} AS metric_time__week , {{ render_date_trunc("c.ds", TimeGranularity.MONTH) }} AS metric_time__month @@ -1290,7 +1290,7 @@ integration_test: ) subq_3 ON subq_5.ds = subq_3.metric_time__day ) subq_7 - INNER JOIN ( + FULL OUTER JOIN ( SELECT subq_11.ds AS metric_time__day , SUM(subq_9.bookings) AS bookings_2_weeks_ago diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml index 5c641dbf52..acfd39d3dd 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml @@ -15,7 +15,8 @@ - + + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml index 4f7b4fba1e..374e7da04d 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml @@ -15,7 +15,8 @@ - + + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_plan__dfp_0.xml index 14e3100122..0e45438be4 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_plan__dfp_0.xml @@ -15,7 +15,8 @@ - + + diff --git a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0.sql index 127ebba768..85eee899d7 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0_optimized.sql index ace6863100..f7d37d45b3 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_derived_metric_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0.sql index 9ee6e81037..d8bb186c28 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index a952516e96..6d1b17b416 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0.sql index 4c269caac4..ff86172aba 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0_optimized.sql index 612203ca28..85492077fe 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 1eca8bda82..b63165d712 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index db8895099d..babc99022a 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 23be1ba20e..81ba9df25d 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index a01918dbd2..9127806db2 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index c6f5d6fd56..345740c7ad 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/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/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 570c54fab1..e0166fe3f3 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/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/DuckDB/test_nested_derived_metric__plan0.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0.sql index d7ab098327..0e23b840ec 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_nested_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0_optimized.sql index 519c4b6ea5..86124d9091 100644 --- a/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 903c3820ae..82f482abd5 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index a04d6e7a77..09cde7d286 100644 --- a/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0.sql index a03cec3919..8e374bcc1b 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0_optimized.sql index 31f8ab6fcc..d808676df4 100644 --- a/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/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_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0.sql index dbb29c4d73..ba7e10edd2 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/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/DuckDB/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0_optimized.sql index bf23abb3af..0b555b1430 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/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_source_scan_optimizer.py/DataflowPlan/test_derived_metric__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric__dfp_0.xml index 4d72662222..e10bd4a7a0 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric__dfp_0.xml @@ -15,7 +15,8 @@ - + + diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric_with_non_derived_metric__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric_with_non_derived_metric__dfp_0.xml index a26d3cb22b..e1d61a2ec1 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric_with_non_derived_metric__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric_with_non_derived_metric__dfp_0.xml @@ -65,7 +65,8 @@ - + + diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfp_0.xml index 5af98e9f24..949bae2ee7 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfp_0.xml @@ -15,7 +15,8 @@ - + + @@ -29,7 +30,8 @@ - + + diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfpo_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfpo_0.xml index dcccd29791..a4137fb8ab 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfpo_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfpo_0.xml @@ -15,7 +15,8 @@ - + + From a14e4153c62292d22712f1290b0bd078d4c591bf Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Fri, 3 Nov 2023 12:58:34 -0700 Subject: [PATCH 4/8] Update SQL engine snapshots --- .../BigQuery/test_derived_metric__plan0.sql | 18 +++---- .../test_derived_metric__plan0_optimized.sql | 18 +++---- ...ved_metric_with_offset_to_grain__plan0.sql | 18 +++---- ..._with_offset_to_grain__plan0_optimized.sql | 18 +++---- ...offset_to_grain_and_granularity__plan0.sql | 18 +++---- ...grain_and_granularity__plan0_optimized.sql | 18 +++---- ...rived_metric_with_offset_window__plan0.sql | 18 +++---- ...ic_with_offset_window__plan0_optimized.sql | 18 +++---- ...h_offset_window_and_granularity__plan0.sql | 18 +++---- ...indow_and_granularity__plan0_optimized.sql | 18 +++---- ...fset_window_and_offset_to_grain__plan0.sql | 18 +++---- ...w_and_offset_to_grain__plan0_optimized.sql | 18 +++---- ...offset_to_grain_and_granularity__plan0.sql | 18 +++---- ...grain_and_granularity__plan0_optimized.sql | 18 +++---- .../test_nested_derived_metric__plan0.sql | 50 ++++++------------- ...nested_derived_metric__plan0_optimized.sql | 50 ++++++------------- .../Databricks/test_derived_metric__plan0.sql | 18 +++---- .../test_derived_metric__plan0_optimized.sql | 18 +++---- ...ved_metric_with_offset_to_grain__plan0.sql | 18 +++---- ..._with_offset_to_grain__plan0_optimized.sql | 18 +++---- ...offset_to_grain_and_granularity__plan0.sql | 18 +++---- ...grain_and_granularity__plan0_optimized.sql | 18 +++---- ...rived_metric_with_offset_window__plan0.sql | 18 +++---- ...ic_with_offset_window__plan0_optimized.sql | 18 +++---- ...h_offset_window_and_granularity__plan0.sql | 18 +++---- ...indow_and_granularity__plan0_optimized.sql | 18 +++---- ...fset_window_and_offset_to_grain__plan0.sql | 18 +++---- ...w_and_offset_to_grain__plan0_optimized.sql | 18 +++---- ...offset_to_grain_and_granularity__plan0.sql | 18 +++---- ...grain_and_granularity__plan0_optimized.sql | 18 +++---- .../test_nested_derived_metric__plan0.sql | 50 ++++++------------- ...nested_derived_metric__plan0_optimized.sql | 50 ++++++------------- .../Postgres/test_derived_metric__plan0.sql | 18 +++---- .../test_derived_metric__plan0_optimized.sql | 18 +++---- ...ved_metric_with_offset_to_grain__plan0.sql | 18 +++---- ..._with_offset_to_grain__plan0_optimized.sql | 18 +++---- ...offset_to_grain_and_granularity__plan0.sql | 18 +++---- ...grain_and_granularity__plan0_optimized.sql | 18 +++---- ...rived_metric_with_offset_window__plan0.sql | 18 +++---- ...ic_with_offset_window__plan0_optimized.sql | 18 +++---- ...h_offset_window_and_granularity__plan0.sql | 18 +++---- ...indow_and_granularity__plan0_optimized.sql | 18 +++---- ...fset_window_and_offset_to_grain__plan0.sql | 18 +++---- ...w_and_offset_to_grain__plan0_optimized.sql | 18 +++---- ...offset_to_grain_and_granularity__plan0.sql | 18 +++---- ...grain_and_granularity__plan0_optimized.sql | 18 +++---- .../test_nested_derived_metric__plan0.sql | 50 ++++++------------- ...nested_derived_metric__plan0_optimized.sql | 50 ++++++------------- .../Redshift/test_derived_metric__plan0.sql | 18 +++---- .../test_derived_metric__plan0_optimized.sql | 18 +++---- ...ved_metric_with_offset_to_grain__plan0.sql | 18 +++---- ..._with_offset_to_grain__plan0_optimized.sql | 18 +++---- ...offset_to_grain_and_granularity__plan0.sql | 18 +++---- ...grain_and_granularity__plan0_optimized.sql | 18 +++---- ...rived_metric_with_offset_window__plan0.sql | 18 +++---- ...ic_with_offset_window__plan0_optimized.sql | 18 +++---- ...h_offset_window_and_granularity__plan0.sql | 18 +++---- ...indow_and_granularity__plan0_optimized.sql | 18 +++---- ...fset_window_and_offset_to_grain__plan0.sql | 18 +++---- ...w_and_offset_to_grain__plan0_optimized.sql | 18 +++---- ...offset_to_grain_and_granularity__plan0.sql | 18 +++---- ...grain_and_granularity__plan0_optimized.sql | 18 +++---- .../test_nested_derived_metric__plan0.sql | 50 ++++++------------- ...nested_derived_metric__plan0_optimized.sql | 50 ++++++------------- .../Snowflake/test_derived_metric__plan0.sql | 18 +++---- .../test_derived_metric__plan0_optimized.sql | 18 +++---- ...ved_metric_with_offset_to_grain__plan0.sql | 18 +++---- ..._with_offset_to_grain__plan0_optimized.sql | 18 +++---- ...offset_to_grain_and_granularity__plan0.sql | 18 +++---- ...grain_and_granularity__plan0_optimized.sql | 18 +++---- ...rived_metric_with_offset_window__plan0.sql | 18 +++---- ...ic_with_offset_window__plan0_optimized.sql | 18 +++---- ...h_offset_window_and_granularity__plan0.sql | 18 +++---- ...indow_and_granularity__plan0_optimized.sql | 18 +++---- ...fset_window_and_offset_to_grain__plan0.sql | 18 +++---- ...w_and_offset_to_grain__plan0_optimized.sql | 18 +++---- ...offset_to_grain_and_granularity__plan0.sql | 18 +++---- ...grain_and_granularity__plan0_optimized.sql | 18 +++---- .../test_nested_derived_metric__plan0.sql | 50 ++++++------------- ...nested_derived_metric__plan0_optimized.sql | 50 ++++++------------- ...fill_nulls_for_one_input_metric__plan0.sql | 18 +++---- ..._for_one_input_metric__plan0_optimized.sql | 18 +++---- ...fill_nulls_for_one_input_metric__plan0.sql | 18 +++---- ..._for_one_input_metric__plan0_optimized.sql | 18 +++---- ...fill_nulls_for_one_input_metric__plan0.sql | 18 +++---- ..._for_one_input_metric__plan0_optimized.sql | 18 +++---- ...fill_nulls_for_one_input_metric__plan0.sql | 18 +++---- ..._for_one_input_metric__plan0_optimized.sql | 18 +++---- ...fill_nulls_for_one_input_metric__plan0.sql | 18 +++---- ..._for_one_input_metric__plan0_optimized.sql | 18 +++---- ...st_offset_window_with_date_part__plan0.sql | 18 +++---- ...window_with_date_part__plan0_optimized.sql | 18 +++---- ...st_offset_window_with_date_part__plan0.sql | 18 +++---- ...window_with_date_part__plan0_optimized.sql | 18 +++---- ...st_offset_window_with_date_part__plan0.sql | 18 +++---- ...window_with_date_part__plan0_optimized.sql | 18 +++---- ...st_offset_window_with_date_part__plan0.sql | 18 +++---- ...window_with_date_part__plan0_optimized.sql | 18 +++---- ...st_offset_window_with_date_part__plan0.sql | 18 +++---- ...window_with_date_part__plan0_optimized.sql | 18 +++---- .../test_measure_constraint__plan0.sql | 32 ++++-------- ...st_measure_constraint__plan0_optimized.sql | 32 ++++-------- .../test_measure_constraint__plan0.sql | 32 ++++-------- ...st_measure_constraint__plan0_optimized.sql | 32 ++++-------- .../test_measure_constraint__plan0.sql | 32 ++++-------- ...st_measure_constraint__plan0_optimized.sql | 32 ++++-------- .../test_measure_constraint__plan0.sql | 32 ++++-------- ...st_measure_constraint__plan0_optimized.sql | 32 ++++-------- .../test_measure_constraint__plan0.sql | 32 ++++-------- ...st_measure_constraint__plan0_optimized.sql | 32 ++++-------- 110 files changed, 780 insertions(+), 1660 deletions(-) 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 From 3e5e8c27f1a0dc1343a2baaff02f20d583e8a761 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Fri, 3 Nov 2023 14:18:54 -0700 Subject: [PATCH 5/8] Update test case SQL --- .../integration/test_cases/itest_metrics.yaml | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/metricflow/test/integration/test_cases/itest_metrics.yaml b/metricflow/test/integration/test_cases/itest_metrics.yaml index 1ae004a3bb..d0d5591ab4 100644 --- a/metricflow/test/integration/test_cases/itest_metrics.yaml +++ b/metricflow/test/integration/test_cases/itest_metrics.yaml @@ -643,27 +643,34 @@ integration_test: group_bys: [listing__is_lux_latest] check_query: | SELECT - bk.booking_value / NULLIF(vw.views, 0) AS booking_value_per_view - , bk.is_lux AS listing__is_lux_latest + booking_value / NULLIF(views, 0) AS booking_value_per_view + , listing__is_lux_latest FROM ( SELECT - SUM(a.booking_value) AS booking_value - ,b.is_lux - FROM {{ source_schema }}.fct_bookings a - LEFT OUTER JOIN {{ source_schema }}.dim_listings_latest b - ON a.listing_id = b.listing_id - GROUP BY 2 - ) bk - FULL OUTER JOIN ( - SELECT - SUM(1) AS views - ,d.is_lux - FROM {{ source_schema }}.fct_views c - LEFT OUTER JOIN {{ source_schema }}.dim_listings_latest d - ON c.listing_id = d.listing_id - GROUP BY 2 - ) vw - ON bk.is_lux = vw.is_lux OR (bk.is_lux IS NULL AND vw.is_lux IS NULL) + MAX(bk.booking_value) AS booking_value + , MAX(vw.views) AS views + , COALESCE(bk.is_lux, vw.is_lux) AS listing__is_lux_latest + FROM ( + SELECT + SUM(a.booking_value) AS booking_value + ,b.is_lux + FROM {{ source_schema }}.fct_bookings a + LEFT OUTER JOIN {{ source_schema }}.dim_listings_latest b + ON a.listing_id = b.listing_id + GROUP BY 2 + ) bk + FULL OUTER JOIN ( + SELECT + SUM(1) AS views + ,d.is_lux + FROM {{ source_schema }}.fct_views c + LEFT OUTER JOIN {{ source_schema }}.dim_listings_latest d + ON c.listing_id = d.listing_id + GROUP BY 2 + ) vw + ON bk.is_lux = vw.is_lux + GROUP BY 3 + ) x --- integration_test: name: derived_metric_with_offset_window From dbb8a2fafaa8012a9b88be7d7e7bb162143ba200 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Fri, 3 Nov 2023 15:40:29 -0700 Subject: [PATCH 6/8] Use FULL OUTER JOIN for ratio metrics, too --- .../dataflow/builder/dataflow_plan_builder.py | 3 +- .../test_cases/itest_measure_constraints.yaml | 10 +- .../integration/test_cases/itest_metrics.yaml | 4 +- ...traint_with_reused_measure_plan__dfp_0.xml | 3 +- ...mantic_model_ratio_metrics_plan__dfp_0.xml | 3 +- ...mantic_model_ratio_metrics_plan__dfp_0.xml | 3 +- ...o_from_multiple_semantic_models__plan0.sql | 25 ++-- ...tiple_semantic_models__plan0_optimized.sql | 134 +++++++++--------- ...o_from_multiple_semantic_models__plan0.sql | 25 ++-- ...tiple_semantic_models__plan0_optimized.sql | 134 +++++++++--------- ...o_from_multiple_semantic_models__plan0.sql | 25 ++-- ...tiple_semantic_models__plan0_optimized.sql | 134 +++++++++--------- ...o_from_multiple_semantic_models__plan0.sql | 25 ++-- ...tiple_semantic_models__plan0_optimized.sql | 134 +++++++++--------- ...o_from_multiple_semantic_models__plan0.sql | 25 ++-- ...tiple_semantic_models__plan0_optimized.sql | 134 +++++++++--------- ...o_from_multiple_semantic_models__plan0.sql | 25 ++-- ...tiple_semantic_models__plan0_optimized.sql | 134 +++++++++--------- ...o_from_multiple_semantic_models__plan0.xml | 32 +++-- ..._constraint_with_reused_measure__plan0.sql | 18 +-- ...t_with_reused_measure__plan0_optimized.sql | 80 +++++------ ..._multiple_sources_no_dimensions__plan0.sql | 4 +- ...sources_no_dimensions__plan0_optimized.sql | 2 +- ..._constraint_with_reused_measure__plan0.sql | 18 +-- ...t_with_reused_measure__plan0_optimized.sql | 82 +++++------ ..._multiple_sources_no_dimensions__plan0.sql | 4 +- ...sources_no_dimensions__plan0_optimized.sql | 2 +- ..._constraint_with_reused_measure__plan0.sql | 18 +-- ...t_with_reused_measure__plan0_optimized.sql | 82 +++++------ ..._multiple_sources_no_dimensions__plan0.sql | 4 +- ...sources_no_dimensions__plan0_optimized.sql | 2 +- ..._constraint_with_reused_measure__plan0.sql | 18 +-- ...t_with_reused_measure__plan0_optimized.sql | 82 +++++------ ..._multiple_sources_no_dimensions__plan0.sql | 4 +- ...sources_no_dimensions__plan0_optimized.sql | 2 +- ..._constraint_with_reused_measure__plan0.sql | 18 +-- ...t_with_reused_measure__plan0_optimized.sql | 82 +++++------ ..._multiple_sources_no_dimensions__plan0.sql | 4 +- ...sources_no_dimensions__plan0_optimized.sql | 2 +- ..._constraint_with_reused_measure__plan0.sql | 18 +-- ...t_with_reused_measure__plan0_optimized.sql | 82 +++++------ ..._multiple_sources_no_dimensions__plan0.sql | 4 +- ...sources_no_dimensions__plan0_optimized.sql | 2 +- ...o_metrics_from_1_semantic_model__dfp_0.xml | 6 +- 44 files changed, 781 insertions(+), 871 deletions(-) diff --git a/metricflow/dataflow/builder/dataflow_plan_builder.py b/metricflow/dataflow/builder/dataflow_plan_builder.py index 650408bbe8..dfa50f7e33 100644 --- a/metricflow/dataflow/builder/dataflow_plan_builder.py +++ b/metricflow/dataflow/builder/dataflow_plan_builder.py @@ -241,14 +241,13 @@ def _build_metrics_output_node( f"For {metric.type} metric: {metric_spec}, needed metrics are:\n" f"{pformat_big_objects(metric_input_specs=metric_input_specs)}" ) - join_type = SqlJoinType.FULL_OUTER if metric.type is MetricType.DERIVED else SqlJoinType.INNER compute_metrics_node = ComputeMetricsNode( parent_node=self._build_metrics_output_node( metric_specs=metric_input_specs, queried_linkable_specs=queried_linkable_specs, where_constraint=where_constraint, time_range_constraint=time_range_constraint, - combine_metrics_join_type=join_type, + combine_metrics_join_type=SqlJoinType.FULL_OUTER, ), metric_specs=[metric_spec], ) diff --git a/metricflow/test/integration/test_cases/itest_measure_constraints.yaml b/metricflow/test/integration/test_cases/itest_measure_constraints.yaml index 77725be38c..d67ffea68f 100644 --- a/metricflow/test/integration/test_cases/itest_measure_constraints.yaml +++ b/metricflow/test/integration/test_cases/itest_measure_constraints.yaml @@ -18,7 +18,7 @@ integration_test: WHERE is_instant GROUP BY ds ) a - JOIN ( + FULL OUTER JOIN ( SELECT CAST(NULLIF(MAX(booking_value), 0) AS {{ double_data_type_name }} ) AS max_booking_value , ds @@ -48,7 +48,7 @@ integration_test: WHERE listings_latest.is_lux GROUP BY fct_bookings.ds ) a - JOIN ( + FULL OUTER JOIN ( SELECT CAST(NULLIF(MAX(booking_value), 0) AS {{ double_data_type_name }} ) AS max_booking_value , ds @@ -79,7 +79,7 @@ integration_test: WHERE listings_latest.is_lux GROUP BY fct_bookings.ds ) a - JOIN ( + FULL OUTER JOIN ( SELECT CAST(NULLIF(SUM(booking_value), 0) AS {{ double_data_type_name }} ) AS booking_value , ds @@ -107,7 +107,7 @@ integration_test: WHERE is_instant GROUP BY ds ) a - JOIN ( + FULL OUTER JOIN ( SELECT CAST(NULLIF(SUM(booking_value), 0) AS {{ double_data_type_name }} ) AS booking_value , ds @@ -153,7 +153,7 @@ integration_test: WHERE dul_west.home_state_latest IN ('CA', 'HI', 'WA') GROUP BY fa_west_filtered.ds ) a - JOIN ( + FULL OUTER JOIN ( SELECT CAST(SUM(account_balance) AS {{ double_data_type_name }}) AS total_account_balance_first_day , fa_east_filtered.ds diff --git a/metricflow/test/integration/test_cases/itest_metrics.yaml b/metricflow/test/integration/test_cases/itest_metrics.yaml index d0d5591ab4..425bae5fb1 100644 --- a/metricflow/test/integration/test_cases/itest_metrics.yaml +++ b/metricflow/test/integration/test_cases/itest_metrics.yaml @@ -284,7 +284,7 @@ integration_test: GROUP BY ds ) groupby_8cbdaa28 - JOIN ( + FULL OUTER JOIN ( SELECT SUM(1) AS views , ds @@ -350,7 +350,7 @@ integration_test: GROUP BY ds ) groupby_8cbdaa28 - JOIN ( + FULL OUTER JOIN ( SELECT SUM(1) AS listings , created_at AS ds diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml index f25d9f6748..ae67a800bb 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml @@ -15,7 +15,8 @@ - + + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml index 7de1511904..8bdcd7e080 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml @@ -15,7 +15,8 @@ - + + diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_single_semantic_model_ratio_metrics_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_single_semantic_model_ratio_metrics_plan__dfp_0.xml index 22856f8489..26a114d041 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_single_semantic_model_ratio_metrics_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_single_semantic_model_ratio_metrics_plan__dfp_0.xml @@ -15,7 +15,8 @@ - + + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index b2a2aec6c3..fc7317598e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -8,8 +8,8 @@ FROM ( SELECT COALESCE(subq_9.ds__day, subq_19.ds__day) AS ds__day , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) AS listing__country_latest - , subq_9.bookings AS bookings - , subq_19.views AS views + , MAX(subq_9.bookings) AS bookings + , MAX(subq_19.views) AS views FROM ( -- Compute Metrics via Expressions SELECT @@ -387,7 +387,7 @@ FROM ( , listing__country_latest ) subq_8 ) subq_9 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_18.ds__day @@ -689,20 +689,11 @@ FROM ( ) subq_19 ON ( - ( - subq_9.listing__country_latest = subq_19.listing__country_latest - ) OR ( - ( - subq_9.listing__country_latest IS NULL - ) AND ( - subq_19.listing__country_latest IS NULL - ) - ) + subq_9.listing__country_latest = subq_19.listing__country_latest ) AND ( - ( - subq_9.ds__day = subq_19.ds__day - ) OR ( - (subq_9.ds__day IS NULL) AND (subq_19.ds__day IS NULL) - ) + subq_9.ds__day = subq_19.ds__day ) + GROUP BY + ds__day + , listing__country_latest ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index e540931fcd..fb551dce52 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -1,82 +1,80 @@ --- Combine Metrics -- Compute Metrics via Expressions SELECT - COALESCE(subq_30.ds__day, subq_40.ds__day) AS ds__day - , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) AS listing__country_latest - , CAST(subq_30.bookings AS FLOAT64) / CAST(NULLIF(subq_40.views, 0) AS FLOAT64) AS bookings_per_view + ds__day + , listing__country_latest + , CAST(bookings AS FLOAT64) / CAST(NULLIF(views, 0) AS FLOAT64) AS bookings_per_view FROM ( - -- Join Standard Outputs - -- Pass Only Elements: - -- ['bookings', 'listing__country_latest', 'ds__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions + -- Combine Metrics SELECT - subq_23.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest - , SUM(subq_23.bookings) AS bookings + COALESCE(subq_30.ds__day, subq_40.ds__day) AS ds__day + , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) AS listing__country_latest + , MAX(subq_30.bookings) AS bookings + , MAX(subq_40.views) AS views FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' + -- Join Standard Outputs -- Pass Only Elements: - -- ['bookings', 'ds__day', 'listing'] + -- ['bookings', 'listing__country_latest', 'ds__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions SELECT - DATE_TRUNC(ds, day) AS ds__day - , listing_id AS listing - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10001 - ) subq_23 - LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 - ON - subq_23.listing = listings_latest_src_10004.listing_id - GROUP BY - ds__day - , listing__country_latest -) subq_30 -INNER JOIN ( - -- Join Standard Outputs - -- Pass Only Elements: - -- ['views', 'listing__country_latest', 'ds__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions - SELECT - subq_33.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest - , SUM(subq_33.views) AS views - FROM ( - -- Read Elements From Semantic Model 'views_source' - -- Metric Time Dimension 'ds' + subq_23.ds__day AS ds__day + , listings_latest_src_10004.country AS listing__country_latest + , SUM(subq_23.bookings) AS bookings + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['bookings', 'ds__day', 'listing'] + SELECT + DATE_TRUNC(ds, day) AS ds__day + , listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_10001 + ) subq_23 + LEFT OUTER JOIN + ***************************.dim_listings_latest listings_latest_src_10004 + ON + subq_23.listing = listings_latest_src_10004.listing_id + GROUP BY + ds__day + , listing__country_latest + ) subq_30 + FULL OUTER JOIN ( + -- Join Standard Outputs -- Pass Only Elements: - -- ['views', 'ds__day', 'listing'] + -- ['views', 'listing__country_latest', 'ds__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions SELECT - DATE_TRUNC(ds, day) AS ds__day - , listing_id AS listing - , 1 AS views - FROM ***************************.fct_views views_source_src_10009 - ) subq_33 - LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + subq_33.ds__day AS ds__day + , listings_latest_src_10004.country AS listing__country_latest + , SUM(subq_33.views) AS views + FROM ( + -- Read Elements From Semantic Model 'views_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['views', 'ds__day', 'listing'] + SELECT + DATE_TRUNC(ds, day) AS ds__day + , listing_id AS listing + , 1 AS views + FROM ***************************.fct_views views_source_src_10009 + ) subq_33 + LEFT OUTER JOIN + ***************************.dim_listings_latest listings_latest_src_10004 + ON + subq_33.listing = listings_latest_src_10004.listing_id + GROUP BY + ds__day + , listing__country_latest + ) subq_40 ON - subq_33.listing = listings_latest_src_10004.listing_id - GROUP BY - ds__day - , listing__country_latest -) subq_40 -ON - ( ( subq_30.listing__country_latest = subq_40.listing__country_latest - ) OR ( - ( - subq_30.listing__country_latest IS NULL - ) AND ( - subq_40.listing__country_latest IS NULL - ) - ) - ) AND ( - ( + ) AND ( subq_30.ds__day = subq_40.ds__day - ) OR ( - (subq_30.ds__day IS NULL) AND (subq_40.ds__day IS NULL) ) - ) + GROUP BY + ds__day + , listing__country_latest +) subq_41 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index cce4a6d693..b619d75d13 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -8,8 +8,8 @@ FROM ( SELECT COALESCE(subq_9.ds__day, subq_19.ds__day) AS ds__day , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) AS listing__country_latest - , subq_9.bookings AS bookings - , subq_19.views AS views + , MAX(subq_9.bookings) AS bookings + , MAX(subq_19.views) AS views FROM ( -- Compute Metrics via Expressions SELECT @@ -387,7 +387,7 @@ FROM ( , subq_7.listing__country_latest ) subq_8 ) subq_9 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_18.ds__day @@ -689,20 +689,11 @@ FROM ( ) subq_19 ON ( - ( - subq_9.listing__country_latest = subq_19.listing__country_latest - ) OR ( - ( - subq_9.listing__country_latest IS NULL - ) AND ( - subq_19.listing__country_latest IS NULL - ) - ) + subq_9.listing__country_latest = subq_19.listing__country_latest ) AND ( - ( - subq_9.ds__day = subq_19.ds__day - ) OR ( - (subq_9.ds__day IS NULL) AND (subq_19.ds__day IS NULL) - ) + subq_9.ds__day = subq_19.ds__day ) + GROUP BY + COALESCE(subq_9.ds__day, subq_19.ds__day) + , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 03f2aa3d7e..b53b1f06f4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -1,82 +1,80 @@ --- Combine Metrics -- Compute Metrics via Expressions SELECT - COALESCE(subq_30.ds__day, subq_40.ds__day) AS ds__day - , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) AS listing__country_latest - , CAST(subq_30.bookings AS DOUBLE) / CAST(NULLIF(subq_40.views, 0) AS DOUBLE) AS bookings_per_view + ds__day + , listing__country_latest + , CAST(bookings AS DOUBLE) / CAST(NULLIF(views, 0) AS DOUBLE) AS bookings_per_view FROM ( - -- Join Standard Outputs - -- Pass Only Elements: - -- ['bookings', 'listing__country_latest', 'ds__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions + -- Combine Metrics SELECT - subq_23.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest - , SUM(subq_23.bookings) AS bookings + COALESCE(subq_30.ds__day, subq_40.ds__day) AS ds__day + , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) AS listing__country_latest + , MAX(subq_30.bookings) AS bookings + , MAX(subq_40.views) AS views FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' + -- Join Standard Outputs -- Pass Only Elements: - -- ['bookings', 'ds__day', 'listing'] + -- ['bookings', 'listing__country_latest', 'ds__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions SELECT - DATE_TRUNC('day', ds) AS ds__day - , listing_id AS listing - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10001 - ) subq_23 - LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 - ON - subq_23.listing = listings_latest_src_10004.listing_id - GROUP BY - subq_23.ds__day - , listings_latest_src_10004.country -) subq_30 -INNER JOIN ( - -- Join Standard Outputs - -- Pass Only Elements: - -- ['views', 'listing__country_latest', 'ds__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions - SELECT - subq_33.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest - , SUM(subq_33.views) AS views - FROM ( - -- Read Elements From Semantic Model 'views_source' - -- Metric Time Dimension 'ds' + subq_23.ds__day AS ds__day + , listings_latest_src_10004.country AS listing__country_latest + , SUM(subq_23.bookings) AS bookings + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['bookings', 'ds__day', 'listing'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_10001 + ) subq_23 + LEFT OUTER JOIN + ***************************.dim_listings_latest listings_latest_src_10004 + ON + subq_23.listing = listings_latest_src_10004.listing_id + GROUP BY + subq_23.ds__day + , listings_latest_src_10004.country + ) subq_30 + FULL OUTER JOIN ( + -- Join Standard Outputs -- Pass Only Elements: - -- ['views', 'ds__day', 'listing'] + -- ['views', 'listing__country_latest', 'ds__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions SELECT - DATE_TRUNC('day', ds) AS ds__day - , listing_id AS listing - , 1 AS views - FROM ***************************.fct_views views_source_src_10009 - ) subq_33 - LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + subq_33.ds__day AS ds__day + , listings_latest_src_10004.country AS listing__country_latest + , SUM(subq_33.views) AS views + FROM ( + -- Read Elements From Semantic Model 'views_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['views', 'ds__day', 'listing'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , listing_id AS listing + , 1 AS views + FROM ***************************.fct_views views_source_src_10009 + ) subq_33 + LEFT OUTER JOIN + ***************************.dim_listings_latest listings_latest_src_10004 + ON + subq_33.listing = listings_latest_src_10004.listing_id + GROUP BY + subq_33.ds__day + , listings_latest_src_10004.country + ) subq_40 ON - subq_33.listing = listings_latest_src_10004.listing_id - GROUP BY - subq_33.ds__day - , listings_latest_src_10004.country -) subq_40 -ON - ( ( subq_30.listing__country_latest = subq_40.listing__country_latest - ) OR ( - ( - subq_30.listing__country_latest IS NULL - ) AND ( - subq_40.listing__country_latest IS NULL - ) - ) - ) AND ( - ( + ) AND ( subq_30.ds__day = subq_40.ds__day - ) OR ( - (subq_30.ds__day IS NULL) AND (subq_40.ds__day IS NULL) ) - ) + GROUP BY + COALESCE(subq_30.ds__day, subq_40.ds__day) + , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) +) subq_41 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index 6a9d428c0a..e945f2d50c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -8,8 +8,8 @@ FROM ( SELECT COALESCE(subq_9.ds__day, subq_19.ds__day) AS ds__day , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) AS listing__country_latest - , subq_9.bookings AS bookings - , subq_19.views AS views + , MAX(subq_9.bookings) AS bookings + , MAX(subq_19.views) AS views FROM ( -- Compute Metrics via Expressions SELECT @@ -387,7 +387,7 @@ FROM ( , subq_7.listing__country_latest ) subq_8 ) subq_9 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_18.ds__day @@ -689,20 +689,11 @@ FROM ( ) subq_19 ON ( - ( - subq_9.listing__country_latest = subq_19.listing__country_latest - ) OR ( - ( - subq_9.listing__country_latest IS NULL - ) AND ( - subq_19.listing__country_latest IS NULL - ) - ) + subq_9.listing__country_latest = subq_19.listing__country_latest ) AND ( - ( - subq_9.ds__day = subq_19.ds__day - ) OR ( - (subq_9.ds__day IS NULL) AND (subq_19.ds__day IS NULL) - ) + subq_9.ds__day = subq_19.ds__day ) + GROUP BY + COALESCE(subq_9.ds__day, subq_19.ds__day) + , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 03f2aa3d7e..b53b1f06f4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -1,82 +1,80 @@ --- Combine Metrics -- Compute Metrics via Expressions SELECT - COALESCE(subq_30.ds__day, subq_40.ds__day) AS ds__day - , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) AS listing__country_latest - , CAST(subq_30.bookings AS DOUBLE) / CAST(NULLIF(subq_40.views, 0) AS DOUBLE) AS bookings_per_view + ds__day + , listing__country_latest + , CAST(bookings AS DOUBLE) / CAST(NULLIF(views, 0) AS DOUBLE) AS bookings_per_view FROM ( - -- Join Standard Outputs - -- Pass Only Elements: - -- ['bookings', 'listing__country_latest', 'ds__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions + -- Combine Metrics SELECT - subq_23.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest - , SUM(subq_23.bookings) AS bookings + COALESCE(subq_30.ds__day, subq_40.ds__day) AS ds__day + , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) AS listing__country_latest + , MAX(subq_30.bookings) AS bookings + , MAX(subq_40.views) AS views FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' + -- Join Standard Outputs -- Pass Only Elements: - -- ['bookings', 'ds__day', 'listing'] + -- ['bookings', 'listing__country_latest', 'ds__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions SELECT - DATE_TRUNC('day', ds) AS ds__day - , listing_id AS listing - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10001 - ) subq_23 - LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 - ON - subq_23.listing = listings_latest_src_10004.listing_id - GROUP BY - subq_23.ds__day - , listings_latest_src_10004.country -) subq_30 -INNER JOIN ( - -- Join Standard Outputs - -- Pass Only Elements: - -- ['views', 'listing__country_latest', 'ds__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions - SELECT - subq_33.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest - , SUM(subq_33.views) AS views - FROM ( - -- Read Elements From Semantic Model 'views_source' - -- Metric Time Dimension 'ds' + subq_23.ds__day AS ds__day + , listings_latest_src_10004.country AS listing__country_latest + , SUM(subq_23.bookings) AS bookings + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['bookings', 'ds__day', 'listing'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_10001 + ) subq_23 + LEFT OUTER JOIN + ***************************.dim_listings_latest listings_latest_src_10004 + ON + subq_23.listing = listings_latest_src_10004.listing_id + GROUP BY + subq_23.ds__day + , listings_latest_src_10004.country + ) subq_30 + FULL OUTER JOIN ( + -- Join Standard Outputs -- Pass Only Elements: - -- ['views', 'ds__day', 'listing'] + -- ['views', 'listing__country_latest', 'ds__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions SELECT - DATE_TRUNC('day', ds) AS ds__day - , listing_id AS listing - , 1 AS views - FROM ***************************.fct_views views_source_src_10009 - ) subq_33 - LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + subq_33.ds__day AS ds__day + , listings_latest_src_10004.country AS listing__country_latest + , SUM(subq_33.views) AS views + FROM ( + -- Read Elements From Semantic Model 'views_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['views', 'ds__day', 'listing'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , listing_id AS listing + , 1 AS views + FROM ***************************.fct_views views_source_src_10009 + ) subq_33 + LEFT OUTER JOIN + ***************************.dim_listings_latest listings_latest_src_10004 + ON + subq_33.listing = listings_latest_src_10004.listing_id + GROUP BY + subq_33.ds__day + , listings_latest_src_10004.country + ) subq_40 ON - subq_33.listing = listings_latest_src_10004.listing_id - GROUP BY - subq_33.ds__day - , listings_latest_src_10004.country -) subq_40 -ON - ( ( subq_30.listing__country_latest = subq_40.listing__country_latest - ) OR ( - ( - subq_30.listing__country_latest IS NULL - ) AND ( - subq_40.listing__country_latest IS NULL - ) - ) - ) AND ( - ( + ) AND ( subq_30.ds__day = subq_40.ds__day - ) OR ( - (subq_30.ds__day IS NULL) AND (subq_40.ds__day IS NULL) ) - ) + GROUP BY + COALESCE(subq_30.ds__day, subq_40.ds__day) + , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) +) subq_41 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index 0252714d7d..19b030239b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -8,8 +8,8 @@ FROM ( SELECT COALESCE(subq_9.ds__day, subq_19.ds__day) AS ds__day , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) AS listing__country_latest - , subq_9.bookings AS bookings - , subq_19.views AS views + , MAX(subq_9.bookings) AS bookings + , MAX(subq_19.views) AS views FROM ( -- Compute Metrics via Expressions SELECT @@ -387,7 +387,7 @@ FROM ( , subq_7.listing__country_latest ) subq_8 ) subq_9 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_18.ds__day @@ -689,20 +689,11 @@ FROM ( ) subq_19 ON ( - ( - subq_9.listing__country_latest = subq_19.listing__country_latest - ) OR ( - ( - subq_9.listing__country_latest IS NULL - ) AND ( - subq_19.listing__country_latest IS NULL - ) - ) + subq_9.listing__country_latest = subq_19.listing__country_latest ) AND ( - ( - subq_9.ds__day = subq_19.ds__day - ) OR ( - (subq_9.ds__day IS NULL) AND (subq_19.ds__day IS NULL) - ) + subq_9.ds__day = subq_19.ds__day ) + GROUP BY + COALESCE(subq_9.ds__day, subq_19.ds__day) + , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 4baa44160e..9526df6729 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -1,82 +1,80 @@ --- Combine Metrics -- Compute Metrics via Expressions SELECT - COALESCE(subq_30.ds__day, subq_40.ds__day) AS ds__day - , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) AS listing__country_latest - , CAST(subq_30.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_40.views, 0) AS DOUBLE PRECISION) AS bookings_per_view + ds__day + , listing__country_latest + , CAST(bookings AS DOUBLE PRECISION) / CAST(NULLIF(views, 0) AS DOUBLE PRECISION) AS bookings_per_view FROM ( - -- Join Standard Outputs - -- Pass Only Elements: - -- ['bookings', 'listing__country_latest', 'ds__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions + -- Combine Metrics SELECT - subq_23.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest - , SUM(subq_23.bookings) AS bookings + COALESCE(subq_30.ds__day, subq_40.ds__day) AS ds__day + , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) AS listing__country_latest + , MAX(subq_30.bookings) AS bookings + , MAX(subq_40.views) AS views FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' + -- Join Standard Outputs -- Pass Only Elements: - -- ['bookings', 'ds__day', 'listing'] + -- ['bookings', 'listing__country_latest', 'ds__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions SELECT - DATE_TRUNC('day', ds) AS ds__day - , listing_id AS listing - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10001 - ) subq_23 - LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 - ON - subq_23.listing = listings_latest_src_10004.listing_id - GROUP BY - subq_23.ds__day - , listings_latest_src_10004.country -) subq_30 -INNER JOIN ( - -- Join Standard Outputs - -- Pass Only Elements: - -- ['views', 'listing__country_latest', 'ds__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions - SELECT - subq_33.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest - , SUM(subq_33.views) AS views - FROM ( - -- Read Elements From Semantic Model 'views_source' - -- Metric Time Dimension 'ds' + subq_23.ds__day AS ds__day + , listings_latest_src_10004.country AS listing__country_latest + , SUM(subq_23.bookings) AS bookings + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['bookings', 'ds__day', 'listing'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_10001 + ) subq_23 + LEFT OUTER JOIN + ***************************.dim_listings_latest listings_latest_src_10004 + ON + subq_23.listing = listings_latest_src_10004.listing_id + GROUP BY + subq_23.ds__day + , listings_latest_src_10004.country + ) subq_30 + FULL OUTER JOIN ( + -- Join Standard Outputs -- Pass Only Elements: - -- ['views', 'ds__day', 'listing'] + -- ['views', 'listing__country_latest', 'ds__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions SELECT - DATE_TRUNC('day', ds) AS ds__day - , listing_id AS listing - , 1 AS views - FROM ***************************.fct_views views_source_src_10009 - ) subq_33 - LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + subq_33.ds__day AS ds__day + , listings_latest_src_10004.country AS listing__country_latest + , SUM(subq_33.views) AS views + FROM ( + -- Read Elements From Semantic Model 'views_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['views', 'ds__day', 'listing'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , listing_id AS listing + , 1 AS views + FROM ***************************.fct_views views_source_src_10009 + ) subq_33 + LEFT OUTER JOIN + ***************************.dim_listings_latest listings_latest_src_10004 + ON + subq_33.listing = listings_latest_src_10004.listing_id + GROUP BY + subq_33.ds__day + , listings_latest_src_10004.country + ) subq_40 ON - subq_33.listing = listings_latest_src_10004.listing_id - GROUP BY - subq_33.ds__day - , listings_latest_src_10004.country -) subq_40 -ON - ( ( subq_30.listing__country_latest = subq_40.listing__country_latest - ) OR ( - ( - subq_30.listing__country_latest IS NULL - ) AND ( - subq_40.listing__country_latest IS NULL - ) - ) - ) AND ( - ( + ) AND ( subq_30.ds__day = subq_40.ds__day - ) OR ( - (subq_30.ds__day IS NULL) AND (subq_40.ds__day IS NULL) ) - ) + GROUP BY + COALESCE(subq_30.ds__day, subq_40.ds__day) + , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) +) subq_41 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index a4dafff587..8efb1d7083 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -8,8 +8,8 @@ FROM ( SELECT COALESCE(subq_9.ds__day, subq_19.ds__day) AS ds__day , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) AS listing__country_latest - , subq_9.bookings AS bookings - , subq_19.views AS views + , MAX(subq_9.bookings) AS bookings + , MAX(subq_19.views) AS views FROM ( -- Compute Metrics via Expressions SELECT @@ -387,7 +387,7 @@ FROM ( , subq_7.listing__country_latest ) subq_8 ) subq_9 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_18.ds__day @@ -689,20 +689,11 @@ FROM ( ) subq_19 ON ( - ( - subq_9.listing__country_latest = subq_19.listing__country_latest - ) OR ( - ( - subq_9.listing__country_latest IS NULL - ) AND ( - subq_19.listing__country_latest IS NULL - ) - ) + subq_9.listing__country_latest = subq_19.listing__country_latest ) AND ( - ( - subq_9.ds__day = subq_19.ds__day - ) OR ( - (subq_9.ds__day IS NULL) AND (subq_19.ds__day IS NULL) - ) + subq_9.ds__day = subq_19.ds__day ) + GROUP BY + COALESCE(subq_9.ds__day, subq_19.ds__day) + , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 4baa44160e..9526df6729 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -1,82 +1,80 @@ --- Combine Metrics -- Compute Metrics via Expressions SELECT - COALESCE(subq_30.ds__day, subq_40.ds__day) AS ds__day - , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) AS listing__country_latest - , CAST(subq_30.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_40.views, 0) AS DOUBLE PRECISION) AS bookings_per_view + ds__day + , listing__country_latest + , CAST(bookings AS DOUBLE PRECISION) / CAST(NULLIF(views, 0) AS DOUBLE PRECISION) AS bookings_per_view FROM ( - -- Join Standard Outputs - -- Pass Only Elements: - -- ['bookings', 'listing__country_latest', 'ds__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions + -- Combine Metrics SELECT - subq_23.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest - , SUM(subq_23.bookings) AS bookings + COALESCE(subq_30.ds__day, subq_40.ds__day) AS ds__day + , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) AS listing__country_latest + , MAX(subq_30.bookings) AS bookings + , MAX(subq_40.views) AS views FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' + -- Join Standard Outputs -- Pass Only Elements: - -- ['bookings', 'ds__day', 'listing'] + -- ['bookings', 'listing__country_latest', 'ds__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions SELECT - DATE_TRUNC('day', ds) AS ds__day - , listing_id AS listing - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10001 - ) subq_23 - LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 - ON - subq_23.listing = listings_latest_src_10004.listing_id - GROUP BY - subq_23.ds__day - , listings_latest_src_10004.country -) subq_30 -INNER JOIN ( - -- Join Standard Outputs - -- Pass Only Elements: - -- ['views', 'listing__country_latest', 'ds__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions - SELECT - subq_33.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest - , SUM(subq_33.views) AS views - FROM ( - -- Read Elements From Semantic Model 'views_source' - -- Metric Time Dimension 'ds' + subq_23.ds__day AS ds__day + , listings_latest_src_10004.country AS listing__country_latest + , SUM(subq_23.bookings) AS bookings + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['bookings', 'ds__day', 'listing'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_10001 + ) subq_23 + LEFT OUTER JOIN + ***************************.dim_listings_latest listings_latest_src_10004 + ON + subq_23.listing = listings_latest_src_10004.listing_id + GROUP BY + subq_23.ds__day + , listings_latest_src_10004.country + ) subq_30 + FULL OUTER JOIN ( + -- Join Standard Outputs -- Pass Only Elements: - -- ['views', 'ds__day', 'listing'] + -- ['views', 'listing__country_latest', 'ds__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions SELECT - DATE_TRUNC('day', ds) AS ds__day - , listing_id AS listing - , 1 AS views - FROM ***************************.fct_views views_source_src_10009 - ) subq_33 - LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + subq_33.ds__day AS ds__day + , listings_latest_src_10004.country AS listing__country_latest + , SUM(subq_33.views) AS views + FROM ( + -- Read Elements From Semantic Model 'views_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['views', 'ds__day', 'listing'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , listing_id AS listing + , 1 AS views + FROM ***************************.fct_views views_source_src_10009 + ) subq_33 + LEFT OUTER JOIN + ***************************.dim_listings_latest listings_latest_src_10004 + ON + subq_33.listing = listings_latest_src_10004.listing_id + GROUP BY + subq_33.ds__day + , listings_latest_src_10004.country + ) subq_40 ON - subq_33.listing = listings_latest_src_10004.listing_id - GROUP BY - subq_33.ds__day - , listings_latest_src_10004.country -) subq_40 -ON - ( ( subq_30.listing__country_latest = subq_40.listing__country_latest - ) OR ( - ( - subq_30.listing__country_latest IS NULL - ) AND ( - subq_40.listing__country_latest IS NULL - ) - ) - ) AND ( - ( + ) AND ( subq_30.ds__day = subq_40.ds__day - ) OR ( - (subq_30.ds__day IS NULL) AND (subq_40.ds__day IS NULL) ) - ) + GROUP BY + COALESCE(subq_30.ds__day, subq_40.ds__day) + , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) +) subq_41 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index e581853f54..81aee1e5e8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -8,8 +8,8 @@ FROM ( SELECT COALESCE(subq_9.ds__day, subq_19.ds__day) AS ds__day , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) AS listing__country_latest - , subq_9.bookings AS bookings - , subq_19.views AS views + , MAX(subq_9.bookings) AS bookings + , MAX(subq_19.views) AS views FROM ( -- Compute Metrics via Expressions SELECT @@ -387,7 +387,7 @@ FROM ( , subq_7.listing__country_latest ) subq_8 ) subq_9 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_18.ds__day @@ -689,20 +689,11 @@ FROM ( ) subq_19 ON ( - ( - subq_9.listing__country_latest = subq_19.listing__country_latest - ) OR ( - ( - subq_9.listing__country_latest IS NULL - ) AND ( - subq_19.listing__country_latest IS NULL - ) - ) + subq_9.listing__country_latest = subq_19.listing__country_latest ) AND ( - ( - subq_9.ds__day = subq_19.ds__day - ) OR ( - (subq_9.ds__day IS NULL) AND (subq_19.ds__day IS NULL) - ) + subq_9.ds__day = subq_19.ds__day ) + GROUP BY + COALESCE(subq_9.ds__day, subq_19.ds__day) + , COALESCE(subq_9.listing__country_latest, subq_19.listing__country_latest) ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 03f2aa3d7e..b53b1f06f4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -1,82 +1,80 @@ --- Combine Metrics -- Compute Metrics via Expressions SELECT - COALESCE(subq_30.ds__day, subq_40.ds__day) AS ds__day - , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) AS listing__country_latest - , CAST(subq_30.bookings AS DOUBLE) / CAST(NULLIF(subq_40.views, 0) AS DOUBLE) AS bookings_per_view + ds__day + , listing__country_latest + , CAST(bookings AS DOUBLE) / CAST(NULLIF(views, 0) AS DOUBLE) AS bookings_per_view FROM ( - -- Join Standard Outputs - -- Pass Only Elements: - -- ['bookings', 'listing__country_latest', 'ds__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions + -- Combine Metrics SELECT - subq_23.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest - , SUM(subq_23.bookings) AS bookings + COALESCE(subq_30.ds__day, subq_40.ds__day) AS ds__day + , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) AS listing__country_latest + , MAX(subq_30.bookings) AS bookings + , MAX(subq_40.views) AS views FROM ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' + -- Join Standard Outputs -- Pass Only Elements: - -- ['bookings', 'ds__day', 'listing'] + -- ['bookings', 'listing__country_latest', 'ds__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions SELECT - DATE_TRUNC('day', ds) AS ds__day - , listing_id AS listing - , 1 AS bookings - FROM ***************************.fct_bookings bookings_source_src_10001 - ) subq_23 - LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 - ON - subq_23.listing = listings_latest_src_10004.listing_id - GROUP BY - subq_23.ds__day - , listings_latest_src_10004.country -) subq_30 -INNER JOIN ( - -- Join Standard Outputs - -- Pass Only Elements: - -- ['views', 'listing__country_latest', 'ds__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions - SELECT - subq_33.ds__day AS ds__day - , listings_latest_src_10004.country AS listing__country_latest - , SUM(subq_33.views) AS views - FROM ( - -- Read Elements From Semantic Model 'views_source' - -- Metric Time Dimension 'ds' + subq_23.ds__day AS ds__day + , listings_latest_src_10004.country AS listing__country_latest + , SUM(subq_23.bookings) AS bookings + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['bookings', 'ds__day', 'listing'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , listing_id AS listing + , 1 AS bookings + FROM ***************************.fct_bookings bookings_source_src_10001 + ) subq_23 + LEFT OUTER JOIN + ***************************.dim_listings_latest listings_latest_src_10004 + ON + subq_23.listing = listings_latest_src_10004.listing_id + GROUP BY + subq_23.ds__day + , listings_latest_src_10004.country + ) subq_30 + FULL OUTER JOIN ( + -- Join Standard Outputs -- Pass Only Elements: - -- ['views', 'ds__day', 'listing'] + -- ['views', 'listing__country_latest', 'ds__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions SELECT - DATE_TRUNC('day', ds) AS ds__day - , listing_id AS listing - , 1 AS views - FROM ***************************.fct_views views_source_src_10009 - ) subq_33 - LEFT OUTER JOIN - ***************************.dim_listings_latest listings_latest_src_10004 + subq_33.ds__day AS ds__day + , listings_latest_src_10004.country AS listing__country_latest + , SUM(subq_33.views) AS views + FROM ( + -- Read Elements From Semantic Model 'views_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['views', 'ds__day', 'listing'] + SELECT + DATE_TRUNC('day', ds) AS ds__day + , listing_id AS listing + , 1 AS views + FROM ***************************.fct_views views_source_src_10009 + ) subq_33 + LEFT OUTER JOIN + ***************************.dim_listings_latest listings_latest_src_10004 + ON + subq_33.listing = listings_latest_src_10004.listing_id + GROUP BY + subq_33.ds__day + , listings_latest_src_10004.country + ) subq_40 ON - subq_33.listing = listings_latest_src_10004.listing_id - GROUP BY - subq_33.ds__day - , listings_latest_src_10004.country -) subq_40 -ON - ( ( subq_30.listing__country_latest = subq_40.listing__country_latest - ) OR ( - ( - subq_30.listing__country_latest IS NULL - ) AND ( - subq_40.listing__country_latest IS NULL - ) - ) - ) AND ( - ( + ) AND ( subq_30.ds__day = subq_40.ds__day - ) OR ( - (subq_30.ds__day IS NULL) AND (subq_40.ds__day IS NULL) ) - ) + GROUP BY + COALESCE(subq_30.ds__day, subq_40.ds__day) + , COALESCE(subq_30.listing__country_latest, subq_40.listing__country_latest) +) subq_41 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml index a20f2ab36a..c7c329e83e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml @@ -22,27 +22,35 @@ - + - + - - - - - - - - + + + + + + + + - - + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql index 3e56dbc93a..2f6627ec7f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) AS metric_time__day - , subq_6.booking_value_with_is_instant_constraint AS booking_value_with_is_instant_constraint - , subq_11.booking_value AS booking_value + , MAX(subq_6.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_11.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT @@ -240,7 +240,7 @@ FROM ( metric_time__day ) subq_5 ) subq_6 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_10.metric_time__day @@ -457,13 +457,7 @@ FROM ( ) subq_10 ) subq_11 ON - ( - subq_6.metric_time__day = subq_11.metric_time__day - ) OR ( - ( - subq_6.metric_time__day IS NULL - ) AND ( - subq_11.metric_time__day IS NULL - ) - ) + subq_6.metric_time__day = subq_11.metric_time__day + GROUP BY + metric_time__day ) subq_12 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0_optimized.sql index c9c233de49..5b744a582e 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -1,53 +1,53 @@ --- Combine Metrics -- Compute Metrics via Expressions SELECT - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day - , CAST(subq_19.booking_value_with_is_instant_constraint AS FLOAT64) / CAST(NULLIF(subq_24.booking_value, 0) AS FLOAT64) AS instant_booking_value_ratio + metric_time__day + , CAST(booking_value_with_is_instant_constraint AS FLOAT64) / CAST(NULLIF(booking_value, 0) AS FLOAT64) AS instant_booking_value_ratio FROM ( - -- Constrain Output with WHERE - -- Pass Only Elements: - -- ['booking_value', 'metric_time__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions + -- Combine Metrics SELECT - metric_time__day - , SUM(booking_value) AS booking_value_with_is_instant_constraint + COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , MAX(subq_19.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_24.booking_value) AS booking_value FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: + -- ['booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + metric_time__day + , SUM(booking_value) AS booking_value_with_is_instant_constraint + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + DATE_TRUNC(ds, day) AS metric_time__day + , is_instant AS booking__is_instant + , booking_value + FROM ***************************.fct_bookings bookings_source_src_10001 + ) subq_15 + WHERE booking__is_instant + GROUP BY + metric_time__day + ) subq_19 + FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' -- Pass Only Elements: - -- ['booking_value', 'booking__is_instant', 'metric_time__day'] + -- ['booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions SELECT DATE_TRUNC(ds, day) AS metric_time__day - , is_instant AS booking__is_instant - , booking_value + , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 - ) subq_15 - WHERE booking__is_instant - GROUP BY - metric_time__day -) subq_19 -INNER JOIN ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: - -- ['booking_value', 'metric_time__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions - SELECT - DATE_TRUNC(ds, day) AS metric_time__day - , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_10001 + GROUP BY + metric_time__day + ) subq_24 + ON + subq_19.metric_time__day = subq_24.metric_time__day GROUP BY metric_time__day -) subq_24 -ON - ( - subq_19.metric_time__day = subq_24.metric_time__day - ) OR ( - ( - subq_19.metric_time__day IS NULL - ) AND ( - subq_24.metric_time__day IS NULL - ) - ) +) subq_25 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index 7427967f1c..4a2b12935f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -4,8 +4,8 @@ SELECT FROM ( -- Combine Metrics SELECT - subq_4.bookings AS bookings - , subq_9.listings AS listings + MAX(subq_4.bookings) AS bookings + , MAX(subq_9.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql index 83d7ab2a40..e66020c868 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Metrics -- Compute Metrics via Expressions SELECT - CAST(subq_15.bookings AS FLOAT64) / CAST(NULLIF(subq_20.listings, 0) AS FLOAT64) AS bookings_per_listing + CAST(MAX(subq_15.bookings) AS FLOAT64) / CAST(NULLIF(MAX(subq_20.listings), 0) AS FLOAT64) AS bookings_per_listing FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql index 805de5201b..4609e7f48e 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) AS metric_time__day - , subq_6.booking_value_with_is_instant_constraint AS booking_value_with_is_instant_constraint - , subq_11.booking_value AS booking_value + , MAX(subq_6.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_11.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT @@ -240,7 +240,7 @@ FROM ( subq_4.metric_time__day ) subq_5 ) subq_6 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_10.metric_time__day @@ -457,13 +457,7 @@ FROM ( ) subq_10 ) subq_11 ON - ( - subq_6.metric_time__day = subq_11.metric_time__day - ) OR ( - ( - subq_6.metric_time__day IS NULL - ) AND ( - subq_11.metric_time__day IS NULL - ) - ) + subq_6.metric_time__day = subq_11.metric_time__day + GROUP BY + COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) ) subq_12 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0_optimized.sql index 36878b678c..77f5d693df 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -1,53 +1,53 @@ --- Combine Metrics -- Compute Metrics via Expressions SELECT - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day - , CAST(subq_19.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_24.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio + metric_time__day + , CAST(booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio FROM ( - -- Constrain Output with WHERE - -- Pass Only Elements: - -- ['booking_value', 'metric_time__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions + -- Combine Metrics SELECT - metric_time__day - , SUM(booking_value) AS booking_value_with_is_instant_constraint + COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , MAX(subq_19.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_24.booking_value) AS booking_value FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: + -- ['booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + metric_time__day + , SUM(booking_value) AS booking_value_with_is_instant_constraint + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , is_instant AS booking__is_instant + , booking_value + FROM ***************************.fct_bookings bookings_source_src_10001 + ) subq_15 + WHERE booking__is_instant + GROUP BY + metric_time__day + ) subq_19 + FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' -- Pass Only Elements: - -- ['booking_value', 'booking__is_instant', 'metric_time__day'] + -- ['booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions SELECT DATE_TRUNC('day', ds) AS metric_time__day - , is_instant AS booking__is_instant - , booking_value + , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 - ) subq_15 - WHERE booking__is_instant - GROUP BY - metric_time__day -) subq_19 -INNER JOIN ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: - -- ['booking_value', 'metric_time__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions - SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_10001 - GROUP BY - DATE_TRUNC('day', ds) -) subq_24 -ON - ( + GROUP BY + DATE_TRUNC('day', ds) + ) subq_24 + ON subq_19.metric_time__day = subq_24.metric_time__day - ) OR ( - ( - subq_19.metric_time__day IS NULL - ) AND ( - subq_24.metric_time__day IS NULL - ) - ) + GROUP BY + COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index bdf1479a4d..e36b3d9819 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -4,8 +4,8 @@ SELECT FROM ( -- Combine Metrics SELECT - subq_4.bookings AS bookings - , subq_9.listings AS listings + MAX(subq_4.bookings) AS bookings + , MAX(subq_9.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql index 9be945ab42..8a1096e90f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Metrics -- Compute Metrics via Expressions SELECT - CAST(subq_15.bookings AS DOUBLE) / CAST(NULLIF(subq_20.listings, 0) AS DOUBLE) AS bookings_per_listing + CAST(MAX(subq_15.bookings) AS DOUBLE) / CAST(NULLIF(MAX(subq_20.listings), 0) AS DOUBLE) AS bookings_per_listing FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0.sql index a2fb429ea9..c4e6b9b0d5 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) AS metric_time__day - , subq_6.booking_value_with_is_instant_constraint AS booking_value_with_is_instant_constraint - , subq_11.booking_value AS booking_value + , MAX(subq_6.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_11.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT @@ -240,7 +240,7 @@ FROM ( subq_4.metric_time__day ) subq_5 ) subq_6 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_10.metric_time__day @@ -457,13 +457,7 @@ FROM ( ) subq_10 ) subq_11 ON - ( - subq_6.metric_time__day = subq_11.metric_time__day - ) OR ( - ( - subq_6.metric_time__day IS NULL - ) AND ( - subq_11.metric_time__day IS NULL - ) - ) + subq_6.metric_time__day = subq_11.metric_time__day + GROUP BY + COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) ) subq_12 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0_optimized.sql index 36878b678c..77f5d693df 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -1,53 +1,53 @@ --- Combine Metrics -- Compute Metrics via Expressions SELECT - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day - , CAST(subq_19.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_24.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio + metric_time__day + , CAST(booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio FROM ( - -- Constrain Output with WHERE - -- Pass Only Elements: - -- ['booking_value', 'metric_time__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions + -- Combine Metrics SELECT - metric_time__day - , SUM(booking_value) AS booking_value_with_is_instant_constraint + COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , MAX(subq_19.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_24.booking_value) AS booking_value FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: + -- ['booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + metric_time__day + , SUM(booking_value) AS booking_value_with_is_instant_constraint + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , is_instant AS booking__is_instant + , booking_value + FROM ***************************.fct_bookings bookings_source_src_10001 + ) subq_15 + WHERE booking__is_instant + GROUP BY + metric_time__day + ) subq_19 + FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' -- Pass Only Elements: - -- ['booking_value', 'booking__is_instant', 'metric_time__day'] + -- ['booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions SELECT DATE_TRUNC('day', ds) AS metric_time__day - , is_instant AS booking__is_instant - , booking_value + , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 - ) subq_15 - WHERE booking__is_instant - GROUP BY - metric_time__day -) subq_19 -INNER JOIN ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: - -- ['booking_value', 'metric_time__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions - SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_10001 - GROUP BY - DATE_TRUNC('day', ds) -) subq_24 -ON - ( + GROUP BY + DATE_TRUNC('day', ds) + ) subq_24 + ON subq_19.metric_time__day = subq_24.metric_time__day - ) OR ( - ( - subq_19.metric_time__day IS NULL - ) AND ( - subq_24.metric_time__day IS NULL - ) - ) + GROUP BY + COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index 6169511027..01f9725d4d 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -4,8 +4,8 @@ SELECT FROM ( -- Combine Metrics SELECT - subq_4.bookings AS bookings - , subq_9.listings AS listings + MAX(subq_4.bookings) AS bookings + , MAX(subq_9.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql index 9be945ab42..8a1096e90f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Metrics -- Compute Metrics via Expressions SELECT - CAST(subq_15.bookings AS DOUBLE) / CAST(NULLIF(subq_20.listings, 0) AS DOUBLE) AS bookings_per_listing + CAST(MAX(subq_15.bookings) AS DOUBLE) / CAST(NULLIF(MAX(subq_20.listings), 0) AS DOUBLE) AS bookings_per_listing FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql index 5493cc3251..d69116c39b 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) AS metric_time__day - , subq_6.booking_value_with_is_instant_constraint AS booking_value_with_is_instant_constraint - , subq_11.booking_value AS booking_value + , MAX(subq_6.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_11.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT @@ -240,7 +240,7 @@ FROM ( subq_4.metric_time__day ) subq_5 ) subq_6 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_10.metric_time__day @@ -457,13 +457,7 @@ FROM ( ) subq_10 ) subq_11 ON - ( - subq_6.metric_time__day = subq_11.metric_time__day - ) OR ( - ( - subq_6.metric_time__day IS NULL - ) AND ( - subq_11.metric_time__day IS NULL - ) - ) + subq_6.metric_time__day = subq_11.metric_time__day + GROUP BY + COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) ) subq_12 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0_optimized.sql index c466ba6856..dca28f5735 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -1,53 +1,53 @@ --- Combine Metrics -- Compute Metrics via Expressions SELECT - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day - , CAST(subq_19.booking_value_with_is_instant_constraint AS DOUBLE PRECISION) / CAST(NULLIF(subq_24.booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_value_ratio + metric_time__day + , CAST(booking_value_with_is_instant_constraint AS DOUBLE PRECISION) / CAST(NULLIF(booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_value_ratio FROM ( - -- Constrain Output with WHERE - -- Pass Only Elements: - -- ['booking_value', 'metric_time__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions + -- Combine Metrics SELECT - metric_time__day - , SUM(booking_value) AS booking_value_with_is_instant_constraint + COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , MAX(subq_19.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_24.booking_value) AS booking_value FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: + -- ['booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + metric_time__day + , SUM(booking_value) AS booking_value_with_is_instant_constraint + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , is_instant AS booking__is_instant + , booking_value + FROM ***************************.fct_bookings bookings_source_src_10001 + ) subq_15 + WHERE booking__is_instant + GROUP BY + metric_time__day + ) subq_19 + FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' -- Pass Only Elements: - -- ['booking_value', 'booking__is_instant', 'metric_time__day'] + -- ['booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions SELECT DATE_TRUNC('day', ds) AS metric_time__day - , is_instant AS booking__is_instant - , booking_value + , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 - ) subq_15 - WHERE booking__is_instant - GROUP BY - metric_time__day -) subq_19 -INNER JOIN ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: - -- ['booking_value', 'metric_time__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions - SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_10001 - GROUP BY - DATE_TRUNC('day', ds) -) subq_24 -ON - ( + GROUP BY + DATE_TRUNC('day', ds) + ) subq_24 + ON subq_19.metric_time__day = subq_24.metric_time__day - ) OR ( - ( - subq_19.metric_time__day IS NULL - ) AND ( - subq_24.metric_time__day IS NULL - ) - ) + GROUP BY + COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index 1c31c9b36b..20f37cdbd8 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -4,8 +4,8 @@ SELECT FROM ( -- Combine Metrics SELECT - subq_4.bookings AS bookings - , subq_9.listings AS listings + MAX(subq_4.bookings) AS bookings + , MAX(subq_9.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql index 331adf393b..31bce3d483 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Metrics -- Compute Metrics via Expressions SELECT - CAST(subq_15.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_20.listings, 0) AS DOUBLE PRECISION) AS bookings_per_listing + CAST(MAX(subq_15.bookings) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_20.listings), 0) AS DOUBLE PRECISION) AS bookings_per_listing FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql index c239e17531..3ffd151578 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) AS metric_time__day - , subq_6.booking_value_with_is_instant_constraint AS booking_value_with_is_instant_constraint - , subq_11.booking_value AS booking_value + , MAX(subq_6.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_11.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT @@ -240,7 +240,7 @@ FROM ( subq_4.metric_time__day ) subq_5 ) subq_6 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_10.metric_time__day @@ -457,13 +457,7 @@ FROM ( ) subq_10 ) subq_11 ON - ( - subq_6.metric_time__day = subq_11.metric_time__day - ) OR ( - ( - subq_6.metric_time__day IS NULL - ) AND ( - subq_11.metric_time__day IS NULL - ) - ) + subq_6.metric_time__day = subq_11.metric_time__day + GROUP BY + COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) ) subq_12 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0_optimized.sql index c466ba6856..dca28f5735 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -1,53 +1,53 @@ --- Combine Metrics -- Compute Metrics via Expressions SELECT - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day - , CAST(subq_19.booking_value_with_is_instant_constraint AS DOUBLE PRECISION) / CAST(NULLIF(subq_24.booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_value_ratio + metric_time__day + , CAST(booking_value_with_is_instant_constraint AS DOUBLE PRECISION) / CAST(NULLIF(booking_value, 0) AS DOUBLE PRECISION) AS instant_booking_value_ratio FROM ( - -- Constrain Output with WHERE - -- Pass Only Elements: - -- ['booking_value', 'metric_time__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions + -- Combine Metrics SELECT - metric_time__day - , SUM(booking_value) AS booking_value_with_is_instant_constraint + COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , MAX(subq_19.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_24.booking_value) AS booking_value FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: + -- ['booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + metric_time__day + , SUM(booking_value) AS booking_value_with_is_instant_constraint + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , is_instant AS booking__is_instant + , booking_value + FROM ***************************.fct_bookings bookings_source_src_10001 + ) subq_15 + WHERE booking__is_instant + GROUP BY + metric_time__day + ) subq_19 + FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' -- Pass Only Elements: - -- ['booking_value', 'booking__is_instant', 'metric_time__day'] + -- ['booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions SELECT DATE_TRUNC('day', ds) AS metric_time__day - , is_instant AS booking__is_instant - , booking_value + , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 - ) subq_15 - WHERE booking__is_instant - GROUP BY - metric_time__day -) subq_19 -INNER JOIN ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: - -- ['booking_value', 'metric_time__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions - SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_10001 - GROUP BY - DATE_TRUNC('day', ds) -) subq_24 -ON - ( + GROUP BY + DATE_TRUNC('day', ds) + ) subq_24 + ON subq_19.metric_time__day = subq_24.metric_time__day - ) OR ( - ( - subq_19.metric_time__day IS NULL - ) AND ( - subq_24.metric_time__day IS NULL - ) - ) + GROUP BY + COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index b18e57eb14..45490517f3 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -4,8 +4,8 @@ SELECT FROM ( -- Combine Metrics SELECT - subq_4.bookings AS bookings - , subq_9.listings AS listings + MAX(subq_4.bookings) AS bookings + , MAX(subq_9.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql index 331adf393b..31bce3d483 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Metrics -- Compute Metrics via Expressions SELECT - CAST(subq_15.bookings AS DOUBLE PRECISION) / CAST(NULLIF(subq_20.listings, 0) AS DOUBLE PRECISION) AS bookings_per_listing + CAST(MAX(subq_15.bookings) AS DOUBLE PRECISION) / CAST(NULLIF(MAX(subq_20.listings), 0) AS DOUBLE PRECISION) AS bookings_per_listing FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql index fcef034238..92e948277e 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql @@ -6,8 +6,8 @@ FROM ( -- Combine Metrics SELECT COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) AS metric_time__day - , subq_6.booking_value_with_is_instant_constraint AS booking_value_with_is_instant_constraint - , subq_11.booking_value AS booking_value + , MAX(subq_6.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_11.booking_value) AS booking_value FROM ( -- Compute Metrics via Expressions SELECT @@ -240,7 +240,7 @@ FROM ( subq_4.metric_time__day ) subq_5 ) subq_6 - INNER JOIN ( + FULL OUTER JOIN ( -- Compute Metrics via Expressions SELECT subq_10.metric_time__day @@ -457,13 +457,7 @@ FROM ( ) subq_10 ) subq_11 ON - ( - subq_6.metric_time__day = subq_11.metric_time__day - ) OR ( - ( - subq_6.metric_time__day IS NULL - ) AND ( - subq_11.metric_time__day IS NULL - ) - ) + subq_6.metric_time__day = subq_11.metric_time__day + GROUP BY + COALESCE(subq_6.metric_time__day, subq_11.metric_time__day) ) subq_12 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0_optimized.sql index 36878b678c..77f5d693df 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -1,53 +1,53 @@ --- Combine Metrics -- Compute Metrics via Expressions SELECT - COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day - , CAST(subq_19.booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(subq_24.booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio + metric_time__day + , CAST(booking_value_with_is_instant_constraint AS DOUBLE) / CAST(NULLIF(booking_value, 0) AS DOUBLE) AS instant_booking_value_ratio FROM ( - -- Constrain Output with WHERE - -- Pass Only Elements: - -- ['booking_value', 'metric_time__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions + -- Combine Metrics SELECT - metric_time__day - , SUM(booking_value) AS booking_value_with_is_instant_constraint + COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) AS metric_time__day + , MAX(subq_19.booking_value_with_is_instant_constraint) AS booking_value_with_is_instant_constraint + , MAX(subq_24.booking_value) AS booking_value FROM ( + -- Constrain Output with WHERE + -- Pass Only Elements: + -- ['booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions + SELECT + metric_time__day + , SUM(booking_value) AS booking_value_with_is_instant_constraint + FROM ( + -- Read Elements From Semantic Model 'bookings_source' + -- Metric Time Dimension 'ds' + -- Pass Only Elements: + -- ['booking_value', 'booking__is_instant', 'metric_time__day'] + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + , is_instant AS booking__is_instant + , booking_value + FROM ***************************.fct_bookings bookings_source_src_10001 + ) subq_15 + WHERE booking__is_instant + GROUP BY + metric_time__day + ) subq_19 + FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' -- Pass Only Elements: - -- ['booking_value', 'booking__is_instant', 'metric_time__day'] + -- ['booking_value', 'metric_time__day'] + -- Aggregate Measures + -- Compute Metrics via Expressions SELECT DATE_TRUNC('day', ds) AS metric_time__day - , is_instant AS booking__is_instant - , booking_value + , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 - ) subq_15 - WHERE booking__is_instant - GROUP BY - metric_time__day -) subq_19 -INNER JOIN ( - -- Read Elements From Semantic Model 'bookings_source' - -- Metric Time Dimension 'ds' - -- Pass Only Elements: - -- ['booking_value', 'metric_time__day'] - -- Aggregate Measures - -- Compute Metrics via Expressions - SELECT - DATE_TRUNC('day', ds) AS metric_time__day - , SUM(booking_value) AS booking_value - FROM ***************************.fct_bookings bookings_source_src_10001 - GROUP BY - DATE_TRUNC('day', ds) -) subq_24 -ON - ( + GROUP BY + DATE_TRUNC('day', ds) + ) subq_24 + ON subq_19.metric_time__day = subq_24.metric_time__day - ) OR ( - ( - subq_19.metric_time__day IS NULL - ) AND ( - subq_24.metric_time__day IS NULL - ) - ) + GROUP BY + COALESCE(subq_19.metric_time__day, subq_24.metric_time__day) +) subq_25 diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index 92e274b621..b7e32bf2f2 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -4,8 +4,8 @@ SELECT FROM ( -- Combine Metrics SELECT - subq_4.bookings AS bookings - , subq_9.listings AS listings + MAX(subq_4.bookings) AS bookings + , MAX(subq_9.listings) AS listings FROM ( -- Compute Metrics via Expressions SELECT diff --git a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql index 9be945ab42..8a1096e90f 100644 --- a/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_query_rendering.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Combine Metrics -- Compute Metrics via Expressions SELECT - CAST(subq_15.bookings AS DOUBLE) / CAST(NULLIF(subq_20.listings, 0) AS DOUBLE) AS bookings_per_listing + CAST(MAX(subq_15.bookings) AS DOUBLE) / CAST(NULLIF(MAX(subq_20.listings), 0) AS DOUBLE) AS bookings_per_listing FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_ratio_metrics_from_1_semantic_model__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_ratio_metrics_from_1_semantic_model__dfp_0.xml index 59b7d47c75..31896ee893 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_ratio_metrics_from_1_semantic_model__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_ratio_metrics_from_1_semantic_model__dfp_0.xml @@ -20,7 +20,8 @@ - + + @@ -126,7 +127,8 @@ - + + From b243aad2a9604746b0678299f4c91517ce496fde Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Fri, 3 Nov 2023 17:09:18 -0700 Subject: [PATCH 7/8] Update docstring for visit_combine_metrics_node --- metricflow/plan_conversion/dataflow_to_sql.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index 4e9417ad03..87b850b937 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -906,12 +906,10 @@ def visit_combine_metrics_node(self, node: CombineMetricsNode) -> SqlDataSet: """Join computed metric datasets together to return a single dataset containing all metrics. This node may exist in one of two situations: when metrics need to be combined in order to produce a single - dataset with all required inputs for a derived metric (in which case the join type is INNER), or when - metrics need to be combined in order to produce a single dataset of output for downstream consumption by - the end user, in which case we will use FULL OUTER JOIN. + dataset with all required inputs for a derived metric, or when metrics need to be combined in order to produce + a single dataset of output for downstream consumption by the end user. - In the case of a multi-data-source FULL OUTER JOIN the join key will be a coalesced set of all previously - seen dimension values. For example: + The join key will be a coalesced set of all previously seen dimension values. For example: FROM ( ... ) subq_9 From 4c4f44021ba0b5881c78a4bd5ff54668c88095d0 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Fri, 3 Nov 2023 17:53:10 -0700 Subject: [PATCH 8/8] Remove join_type param --- .../dataflow/builder/dataflow_plan_builder.py | 8 +----- metricflow/dataflow/dataflow_plan.py | 25 ++----------------- .../source_scan/source_scan_optimizer.py | 4 +-- metricflow/plan_conversion/dataflow_to_sql.py | 6 ++--- .../test_common_semantic_model__dfp_0.xml | 2 -- ..._derived_metric_offset_to_grain__dfp_0.xml | 2 -- ...in_to_time_spine_derived_metric__dfp_0.xml | 2 -- .../test_measure_constraint_plan__dfp_0.xml | 2 -- ...traint_with_reused_measure_plan__dfp_0.xml | 2 -- ...mantic_model_ratio_metrics_plan__dfp_0.xml | 2 -- .../test_multiple_metrics_plan__dfp_0.xml | 2 -- ...mantic_model_ratio_metrics_plan__dfp_0.xml | 2 -- ...2_metrics_from_1_semantic_model__dfp_0.xml | 2 -- ..._metrics_from_2_semantic_models__dfp_0.xml | 2 -- ...metrics_from_2_semantic_models__dfpo_0.xml | 2 -- ...o_metrics_from_1_semantic_model__dfp_0.xml | 6 ----- ..._metrics_from_2_semantic_models__dfp_0.xml | 2 -- ...metrics_from_2_semantic_models__dfpo_0.xml | 2 -- ...constrained_metric_not_combined__dfp_0.xml | 2 -- ...onstrained_metric_not_combined__dfpo_0.xml | 2 -- .../test_derived_metric__dfp_0.xml | 2 -- ..._metric_with_non_derived_metric__dfp_0.xml | 4 --- ...metric_with_non_derived_metric__dfpo_0.xml | 2 -- .../test_nested_derived_metric__dfp_0.xml | 4 --- .../test_nested_derived_metric__dfpo_0.xml | 2 -- 25 files changed, 7 insertions(+), 86 deletions(-) diff --git a/metricflow/dataflow/builder/dataflow_plan_builder.py b/metricflow/dataflow/builder/dataflow_plan_builder.py index dfa50f7e33..c0b5c146bb 100644 --- a/metricflow/dataflow/builder/dataflow_plan_builder.py +++ b/metricflow/dataflow/builder/dataflow_plan_builder.py @@ -213,7 +213,6 @@ def _build_metrics_output_node( queried_linkable_specs: LinkableSpecSet, where_constraint: Optional[WhereFilterSpec] = None, time_range_constraint: Optional[TimeRangeConstraint] = None, - combine_metrics_join_type: SqlJoinType = SqlJoinType.FULL_OUTER, ) -> BaseOutput: """Builds a computed metrics output node. @@ -222,7 +221,6 @@ def _build_metrics_output_node( queried_linkable_specs: Dimensions/entities that were queried for. where_constraint: Where constraint used to compute the metric. time_range_constraint: Time range constraint used to compute the metric. - combine_metrics_join_type: The join used when combining the computed metrics. """ output_nodes: List[BaseOutput] = [] compute_metrics_node: Optional[ComputeMetricsNode] = None @@ -247,7 +245,6 @@ def _build_metrics_output_node( queried_linkable_specs=queried_linkable_specs, where_constraint=where_constraint, time_range_constraint=time_range_constraint, - combine_metrics_join_type=SqlJoinType.FULL_OUTER, ), metric_specs=[metric_spec], ) @@ -294,10 +291,7 @@ def _build_metrics_output_node( if len(output_nodes) == 1: return output_nodes[0] - return CombineMetricsNode( - parent_nodes=output_nodes, - join_type=combine_metrics_join_type, - ) + return CombineMetricsNode(parent_nodes=output_nodes) def build_plan_for_distinct_values(self, query_spec: MetricFlowQuerySpec) -> DataflowPlan: """Generate a plan that would get the distinct values of a linkable instance. diff --git a/metricflow/dataflow/dataflow_plan.py b/metricflow/dataflow/dataflow_plan.py index 0a2140aedb..1449b88723 100644 --- a/metricflow/dataflow/dataflow_plan.py +++ b/metricflow/dataflow/dataflow_plan.py @@ -1225,9 +1225,7 @@ class CombineMetricsNode(ComputedMetricsOutput): def __init__( # noqa: D self, parent_nodes: Sequence[Union[BaseOutput, ComputedMetricsOutput]], - join_type: SqlJoinType = SqlJoinType.FULL_OUTER, ) -> None: - self._join_type = join_type super().__init__(node_id=self.create_unique_id(), parent_nodes=list(parent_nodes)) @classmethod @@ -1241,31 +1239,12 @@ def accept(self, visitor: DataflowPlanNodeVisitor[VisitorOutputT]) -> VisitorOut def description(self) -> str: # noqa: D return "Combine Metrics" - @property - def displayed_properties(self) -> List[DisplayedProperty]: - """Prints details about the join types and how the node will behave.""" - custom_properties = [DisplayedProperty("join type", self.join_type)] - if self.join_type is SqlJoinType.FULL_OUTER: - custom_properties.append( - DisplayedProperty("de-duplication method", "post-join aggregation across all dimensions") - ) - - return super().displayed_properties + custom_properties - - @property - def join_type(self) -> SqlJoinType: - """The type of join used for combining metrics.""" - return self._join_type - def functionally_identical(self, other_node: DataflowPlanNode) -> bool: # noqa: D - return isinstance(other_node, self.__class__) and other_node.join_type == self.join_type + return isinstance(other_node, self.__class__) def with_new_parents(self, new_parent_nodes: Sequence[BaseOutput]) -> CombineMetricsNode: # noqa: D assert len(new_parent_nodes) == 1 - return CombineMetricsNode( - parent_nodes=new_parent_nodes, - join_type=self.join_type, - ) + return CombineMetricsNode(parent_nodes=new_parent_nodes) class ConstrainTimeRangeNode(AggregatedMeasuresOutput, BaseOutput): diff --git a/metricflow/dataflow/optimizer/source_scan/source_scan_optimizer.py b/metricflow/dataflow/optimizer/source_scan/source_scan_optimizer.py index 5938c63836..26beacef35 100644 --- a/metricflow/dataflow/optimizer/source_scan/source_scan_optimizer.py +++ b/metricflow/dataflow/optimizer/source_scan/source_scan_optimizer.py @@ -287,9 +287,7 @@ def visit_combine_metrics_node(self, node: CombineMetricsNode) -> OptimizeBranch if len(combined_parent_branches) == 1: return OptimizeBranchResult(base_output_node=combined_parent_branches[0]) - return OptimizeBranchResult( - base_output_node=CombineMetricsNode(parent_nodes=combined_parent_branches, join_type=node.join_type) - ) + return OptimizeBranchResult(base_output_node=CombineMetricsNode(parent_nodes=combined_parent_branches)) def visit_constrain_time_range_node(self, node: ConstrainTimeRangeNode) -> OptimizeBranchResult: # noqa: D self._log_visit_node_type(node) diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index 87b850b937..e403f3648e 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -959,7 +959,7 @@ def visit_combine_metrics_node(self, node: CombineMetricsNode) -> SqlDataSet: ), "All parent nodes should have the same set of linkable instances since all values are coalesced." linkable_spec_set = from_data_set.data_set.instance_set.spec_set.transform(SelectOnlyLinkableSpecs()) - join_type = SqlJoinType.CROSS_JOIN if len(linkable_spec_set.all_specs) == 0 else node.join_type + join_type = SqlJoinType.CROSS_JOIN if len(linkable_spec_set.all_specs) == 0 else SqlJoinType.FULL_OUTER joins_descriptions: List[SqlJoinDescription] = [] # TODO: refactor this loop into SqlQueryPlanJoinBuilder @@ -984,7 +984,7 @@ def visit_combine_metrics_node(self, node: CombineMetricsNode) -> SqlDataSet: output_instance_set = InstanceSet.merge([x.data_set.instance_set for x in parent_data_sets]) output_instance_set = output_instance_set.transform(ChangeAssociatedColumns(self._column_association_resolver)) - metric_aggregation_type = AggregationType.MAX if node.join_type is SqlJoinType.FULL_OUTER else None + metric_aggregation_type = AggregationType.MAX metric_select_column_set = SelectColumnSet( metric_columns=self._make_select_columns_for_metrics( table_alias_to_metric_specs, aggregation_type=metric_aggregation_type @@ -1006,7 +1006,7 @@ def visit_combine_metrics_node(self, node: CombineMetricsNode) -> SqlDataSet: from_source=from_data_set.data_set.sql_select_node, from_source_alias=from_data_set.alias, joins_descs=tuple(joins_descriptions), - group_bys=linkable_select_column_set.as_tuple() if node.join_type is SqlJoinType.FULL_OUTER else (), + group_bys=linkable_select_column_set.as_tuple(), where=None, order_bys=(), ), diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_common_semantic_model__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_common_semantic_model__dfp_0.xml index ff9c8b4707..995d2264c8 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_common_semantic_model__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_common_semantic_model__dfp_0.xml @@ -5,8 +5,6 @@ - - diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml index acfd39d3dd..6e7a05c15d 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml @@ -15,8 +15,6 @@ - - diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml index 374e7da04d..ba0faa72af 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml @@ -15,8 +15,6 @@ - - diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_plan__dfp_0.xml index 0e45438be4..c284514433 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_plan__dfp_0.xml @@ -15,8 +15,6 @@ - - diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml index ae67a800bb..37e1a3123e 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_measure_constraint_with_reused_measure_plan__dfp_0.xml @@ -15,8 +15,6 @@ - - diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml index 8bdcd7e080..2688100204 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multi_semantic_model_ratio_metrics_plan__dfp_0.xml @@ -15,8 +15,6 @@ - - diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multiple_metrics_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multiple_metrics_plan__dfp_0.xml index 7234390739..455487089d 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multiple_metrics_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_multiple_metrics_plan__dfp_0.xml @@ -5,8 +5,6 @@ - - diff --git a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_single_semantic_model_ratio_metrics_plan__dfp_0.xml b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_single_semantic_model_ratio_metrics_plan__dfp_0.xml index 26a114d041..ad2e199a63 100644 --- a/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_single_semantic_model_ratio_metrics_plan__dfp_0.xml +++ b/metricflow/test/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_single_semantic_model_ratio_metrics_plan__dfp_0.xml @@ -15,8 +15,6 @@ - - diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_1_semantic_model__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_1_semantic_model__dfp_0.xml index ff9c8b4707..995d2264c8 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_1_semantic_model__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_1_semantic_model__dfp_0.xml @@ -5,8 +5,6 @@ - - diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_2_semantic_models__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_2_semantic_models__dfp_0.xml index cb3913a1e9..4349bbc86d 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_2_semantic_models__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_2_semantic_models__dfp_0.xml @@ -5,8 +5,6 @@ - - diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_2_semantic_models__dfpo_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_2_semantic_models__dfpo_0.xml index 29f009e284..ccbea73132 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_2_semantic_models__dfpo_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_metrics_from_2_semantic_models__dfpo_0.xml @@ -5,8 +5,6 @@ - - diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_ratio_metrics_from_1_semantic_model__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_ratio_metrics_from_1_semantic_model__dfp_0.xml index 31896ee893..b70b76fb45 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_ratio_metrics_from_1_semantic_model__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_2_ratio_metrics_from_1_semantic_model__dfp_0.xml @@ -5,8 +5,6 @@ - - @@ -20,8 +18,6 @@ - - @@ -127,8 +123,6 @@ - - diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_3_metrics_from_2_semantic_models__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_3_metrics_from_2_semantic_models__dfp_0.xml index af1adfb56f..c577d49dac 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_3_metrics_from_2_semantic_models__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_3_metrics_from_2_semantic_models__dfp_0.xml @@ -5,8 +5,6 @@ - - diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_3_metrics_from_2_semantic_models__dfpo_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_3_metrics_from_2_semantic_models__dfpo_0.xml index 1536e6c8f9..4d3f2c07ad 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_3_metrics_from_2_semantic_models__dfpo_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_3_metrics_from_2_semantic_models__dfpo_0.xml @@ -5,8 +5,6 @@ - - diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml index ce2766cc9f..75c50ed00d 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfp_0.xml @@ -5,8 +5,6 @@ - - diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfpo_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfpo_0.xml index aa11bdf2c4..92b366667f 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfpo_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_constrained_metric_not_combined__dfpo_0.xml @@ -5,8 +5,6 @@ - - diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric__dfp_0.xml index e10bd4a7a0..29526bca43 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric__dfp_0.xml @@ -15,8 +15,6 @@ - - diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric_with_non_derived_metric__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric_with_non_derived_metric__dfp_0.xml index e1d61a2ec1..f9e04cae8b 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric_with_non_derived_metric__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric_with_non_derived_metric__dfp_0.xml @@ -5,8 +5,6 @@ - - @@ -65,8 +63,6 @@ - - diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric_with_non_derived_metric__dfpo_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric_with_non_derived_metric__dfpo_0.xml index b23dd5f90b..95b7f60916 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric_with_non_derived_metric__dfpo_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_derived_metric_with_non_derived_metric__dfpo_0.xml @@ -5,8 +5,6 @@ - - diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfp_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfp_0.xml index 949bae2ee7..1c4e8d0e42 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfp_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfp_0.xml @@ -15,8 +15,6 @@ - - @@ -30,8 +28,6 @@ - - diff --git a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfpo_0.xml b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfpo_0.xml index a4137fb8ab..09232c4bd3 100644 --- a/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfpo_0.xml +++ b/metricflow/test/snapshots/test_source_scan_optimizer.py/DataflowPlan/test_nested_derived_metric__dfpo_0.xml @@ -15,8 +15,6 @@ - -