diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/DuckDB/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/DuckDB/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql
index 1bab2d34d..679bf3b37 100644
--- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/DuckDB/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql
+++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlPlan/DuckDB/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql
@@ -15,6 +15,13 @@ WITH sma_28019_cte AS (
FROM ***************************.fct_visits visits_source_src_28000
)
+, rss_28018_cte AS (
+ -- Read From Time Spine 'mf_time_spine'
+ SELECT
+ ds AS ds__day
+ FROM ***************************.mf_time_spine time_spine_src_28006
+)
+
SELECT
metric_time__day AS metric_time__day
, CAST(buys AS DOUBLE) / CAST(NULLIF(visits, 0) AS DOUBLE) AS visit_buy_conversion_rate_7days_fill_nulls_with_0
@@ -27,9 +34,9 @@ FROM (
FROM (
-- Join to Time Spine Dataset
SELECT
- time_spine_src_28006.ds AS metric_time__day
+ rss_28018_cte.ds__day AS metric_time__day
, subq_26.visits AS visits
- FROM ***************************.mf_time_spine time_spine_src_28006
+ FROM rss_28018_cte rss_28018_cte
LEFT OUTER JOIN (
-- Read From CTE For node_id=sma_28019
-- Pass Only Elements: ['visits', 'metric_time__day']
@@ -42,14 +49,14 @@ FROM (
metric_time__day
) subq_26
ON
- time_spine_src_28006.ds = subq_26.metric_time__day
+ rss_28018_cte.ds__day = subq_26.metric_time__day
) subq_30
FULL OUTER JOIN (
-- Join to Time Spine Dataset
SELECT
- time_spine_src_28006.ds AS metric_time__day
+ rss_28018_cte.ds__day AS metric_time__day
, subq_39.buys AS buys
- FROM ***************************.mf_time_spine time_spine_src_28006
+ FROM rss_28018_cte rss_28018_cte
LEFT OUTER JOIN (
-- Find conversions for user within the range of 7 day
-- Pass Only Elements: ['buys', 'metric_time__day']
@@ -113,7 +120,7 @@ FROM (
metric_time__day
) subq_39
ON
- time_spine_src_28006.ds = subq_39.metric_time__day
+ rss_28018_cte.ds__day = subq_39.metric_time__day
) subq_43
ON
subq_30.metric_time__day = subq_43.metric_time__day
diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml
index 895447530..2aa21a591 100644
--- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml
+++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml
@@ -95,6 +95,49 @@ docstring:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml
index 7c4a6e7d1..3205a5666 100644
--- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml
+++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml
@@ -61,6 +61,49 @@ docstring:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_with_granularity__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_with_granularity__dfp_0.xml
index 89a252d0c..1f2f626d4 100644
--- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_with_granularity__dfp_0.xml
+++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_with_granularity__dfp_0.xml
@@ -59,6 +59,65 @@ test_filename: test_dataflow_plan_builder.py
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml
index 6e835d608..2e15cc47f 100644
--- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml
+++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml
@@ -72,6 +72,49 @@ test_filename: test_dataflow_plan_builder.py
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml
index c28929cd5..673f4b0e4 100644
--- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml
+++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml
@@ -62,6 +62,44 @@ test_filename: test_dataflow_plan_builder.py
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -130,9 +168,97 @@ test_filename: test_dataflow_plan_builder.py
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_filters__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_filters__dfp_0.xml
index eafb91229..bdf347c5e 100644
--- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_filters__dfp_0.xml
+++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_filters__dfp_0.xml
@@ -150,6 +150,91 @@ docstring:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_metric_time__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_metric_time__dfp_0.xml
index c4855938b..a96969a0f 100644
--- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_metric_time__dfp_0.xml
+++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_metric_time__dfp_0.xml
@@ -51,6 +51,41 @@ test_filename: test_dataflow_plan_builder.py
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml
index 0fe9a4187..a940f96ca 100644
--- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml
+++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml
@@ -84,11 +84,96 @@ test_filename: test_dataflow_plan_builder.py
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_to_grain_metric_filter_and_query_have_different_granularities__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_to_grain_metric_filter_and_query_have_different_granularities__dfp_0.xml
index 24643e555..22b037b1e 100644
--- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_to_grain_metric_filter_and_query_have_different_granularities__dfp_0.xml
+++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_to_grain_metric_filter_and_query_have_different_granularities__dfp_0.xml
@@ -187,6 +187,68 @@ docstring:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_window_metric_filter_and_query_have_different_granularities__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_window_metric_filter_and_query_have_different_granularities__dfp_0.xml
index 9888e180e..fe934c12c 100644
--- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_window_metric_filter_and_query_have_different_granularities__dfp_0.xml
+++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_window_metric_filter_and_query_have_different_granularities__dfp_0.xml
@@ -192,6 +192,72 @@ docstring:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql
index 55af5dcf2..d1ff51240 100644
--- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql
+++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql
@@ -12,6 +12,13 @@ WITH sma_28009_cte AS (
FROM ***************************.fct_bookings bookings_source_src_28000
)
+, rss_28018_cte AS (
+ -- Read From Time Spine 'mf_time_spine'
+ SELECT
+ ds AS ds__day
+ FROM ***************************.mf_time_spine time_spine_src_28006
+)
+
SELECT
metric_time__day AS metric_time__day
, month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior
@@ -27,15 +34,15 @@ FROM (
-- Aggregate Measures
-- Compute Metrics via Expressions
SELECT
- time_spine_src_28006.ds AS metric_time__day
+ rss_28018_cte.ds__day AS metric_time__day
, SUM(sma_28009_cte.bookings) AS month_start_bookings
- FROM ***************************.mf_time_spine time_spine_src_28006
+ FROM rss_28018_cte rss_28018_cte
INNER JOIN
sma_28009_cte sma_28009_cte
ON
- DATE_TRUNC('month', time_spine_src_28006.ds) = sma_28009_cte.metric_time__day
+ DATE_TRUNC('month', rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day
GROUP BY
- time_spine_src_28006.ds
+ rss_28018_cte.ds__day
) subq_27
FULL OUTER JOIN (
-- Join to Time Spine Dataset
@@ -43,15 +50,15 @@ FROM (
-- Aggregate Measures
-- Compute Metrics via Expressions
SELECT
- time_spine_src_28006.ds AS metric_time__day
+ rss_28018_cte.ds__day AS metric_time__day
, SUM(sma_28009_cte.bookings) AS bookings_1_month_ago
- FROM ***************************.mf_time_spine time_spine_src_28006
+ FROM rss_28018_cte rss_28018_cte
INNER JOIN
sma_28009_cte sma_28009_cte
ON
- time_spine_src_28006.ds - INTERVAL 1 month = sma_28009_cte.metric_time__day
+ rss_28018_cte.ds__day - INTERVAL 1 month = sma_28009_cte.metric_time__day
GROUP BY
- time_spine_src_28006.ds
+ rss_28018_cte.ds__day
) subq_35
ON
subq_27.metric_time__day = subq_35.metric_time__day
diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql
index 1bc7c8040..5e12f4213 100644
--- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql
+++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql
@@ -12,6 +12,14 @@ WITH sma_28009_cte AS (
FROM ***************************.fct_bookings bookings_source_src_28000
)
+, rss_28018_cte AS (
+ -- Read From Time Spine 'mf_time_spine'
+ SELECT
+ ds AS ds__day
+ , DATE_TRUNC('year', ds) AS ds__year
+ FROM ***************************.mf_time_spine time_spine_src_28006
+)
+
SELECT
metric_time__year AS metric_time__year
, month_start_bookings - bookings_1_month_ago AS bookings_month_start_compared_to_1_month_prior
@@ -27,16 +35,16 @@ FROM (
-- Aggregate Measures
-- Compute Metrics via Expressions
SELECT
- DATE_TRUNC('year', time_spine_src_28006.ds) AS metric_time__year
+ rss_28018_cte.ds__year AS metric_time__year
, SUM(sma_28009_cte.bookings) AS month_start_bookings
- FROM ***************************.mf_time_spine time_spine_src_28006
+ FROM rss_28018_cte rss_28018_cte
INNER JOIN
sma_28009_cte sma_28009_cte
ON
- DATE_TRUNC('month', time_spine_src_28006.ds) = sma_28009_cte.metric_time__day
- WHERE DATE_TRUNC('year', time_spine_src_28006.ds) = time_spine_src_28006.ds
+ DATE_TRUNC('month', rss_28018_cte.ds__day) = sma_28009_cte.metric_time__day
+ WHERE rss_28018_cte.ds__year = rss_28018_cte.ds__day
GROUP BY
- DATE_TRUNC('year', time_spine_src_28006.ds)
+ rss_28018_cte.ds__year
) subq_27
FULL OUTER JOIN (
-- Join to Time Spine Dataset
@@ -44,15 +52,15 @@ FROM (
-- Aggregate Measures
-- Compute Metrics via Expressions
SELECT
- DATE_TRUNC('year', time_spine_src_28006.ds) AS metric_time__year
+ rss_28018_cte.ds__year AS metric_time__year
, SUM(sma_28009_cte.bookings) AS bookings_1_month_ago
- FROM ***************************.mf_time_spine time_spine_src_28006
+ FROM rss_28018_cte rss_28018_cte
INNER JOIN
sma_28009_cte sma_28009_cte
ON
- time_spine_src_28006.ds - INTERVAL 1 month = sma_28009_cte.metric_time__day
+ rss_28018_cte.ds__day - INTERVAL 1 month = sma_28009_cte.metric_time__day
GROUP BY
- DATE_TRUNC('year', time_spine_src_28006.ds)
+ rss_28018_cte.ds__year
) subq_35
ON
subq_27.metric_time__year = subq_35.metric_time__year
diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql
index 42b724326..c513d92b9 100644
--- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql
+++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql
@@ -3,8 +3,15 @@ test_filename: test_derived_metric_rendering.py
sql_engine: DuckDB
---
-- Compute Metrics via Expressions
+WITH rss_28018_cte AS (
+ -- Read From Time Spine 'mf_time_spine'
+ SELECT
+ ds AS ds__day
+ FROM ***************************.mf_time_spine time_spine_src_28006
+)
+
SELECT
- metric_time__day
+ metric_time__day AS metric_time__day
, 2 * bookings_offset_once AS bookings_offset_twice
FROM (
-- Constrain Output with WHERE
@@ -15,10 +22,10 @@ FROM (
FROM (
-- Join to Time Spine Dataset
SELECT
- time_spine_src_28006.ds AS metric_time__day
+ rss_28018_cte.ds__day AS metric_time__day
, subq_25.booking__is_instant AS booking__is_instant
, subq_25.bookings_offset_once AS bookings_offset_once
- FROM ***************************.mf_time_spine time_spine_src_28006
+ FROM rss_28018_cte rss_28018_cte
INNER JOIN (
-- Compute Metrics via Expressions
SELECT
@@ -31,10 +38,10 @@ FROM (
-- Aggregate Measures
-- Compute Metrics via Expressions
SELECT
- time_spine_src_28006.ds AS metric_time__day
+ rss_28018_cte.ds__day AS metric_time__day
, subq_17.booking__is_instant AS booking__is_instant
, SUM(subq_17.bookings) AS bookings
- FROM ***************************.mf_time_spine time_spine_src_28006
+ FROM rss_28018_cte rss_28018_cte
INNER JOIN (
-- Read Elements From Semantic Model 'bookings_source'
-- Metric Time Dimension 'ds'
@@ -45,14 +52,14 @@ FROM (
FROM ***************************.fct_bookings bookings_source_src_28000
) subq_17
ON
- time_spine_src_28006.ds - INTERVAL 5 day = subq_17.metric_time__day
+ rss_28018_cte.ds__day - INTERVAL 5 day = subq_17.metric_time__day
GROUP BY
- time_spine_src_28006.ds
+ rss_28018_cte.ds__day
, subq_17.booking__is_instant
) subq_24
) subq_25
ON
- time_spine_src_28006.ds - INTERVAL 2 day = subq_25.metric_time__day
+ rss_28018_cte.ds__day - INTERVAL 2 day = subq_25.metric_time__day
) subq_29
WHERE booking__is_instant
) subq_31
diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets__plan0_optimized.sql
index fe15c86bd..807a5bbaa 100644
--- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets__plan0_optimized.sql
+++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets__plan0_optimized.sql
@@ -3,15 +3,22 @@ test_filename: test_derived_metric_rendering.py
sql_engine: DuckDB
---
-- Compute Metrics via Expressions
+WITH rss_28018_cte AS (
+ -- Read From Time Spine 'mf_time_spine'
+ SELECT
+ ds AS ds__day
+ FROM ***************************.mf_time_spine time_spine_src_28006
+)
+
SELECT
- metric_time__day
+ metric_time__day AS metric_time__day
, 2 * bookings_offset_once AS bookings_offset_twice
FROM (
-- Join to Time Spine Dataset
SELECT
- time_spine_src_28006.ds AS metric_time__day
+ rss_28018_cte.ds__day AS metric_time__day
, subq_23.bookings_offset_once AS bookings_offset_once
- FROM ***************************.mf_time_spine time_spine_src_28006
+ FROM rss_28018_cte rss_28018_cte
INNER JOIN (
-- Compute Metrics via Expressions
SELECT
@@ -23,9 +30,9 @@ FROM (
-- Aggregate Measures
-- Compute Metrics via Expressions
SELECT
- time_spine_src_28006.ds AS metric_time__day
+ rss_28018_cte.ds__day AS metric_time__day
, SUM(subq_15.bookings) AS bookings
- FROM ***************************.mf_time_spine time_spine_src_28006
+ FROM rss_28018_cte rss_28018_cte
INNER JOIN (
-- Read Elements From Semantic Model 'bookings_source'
-- Metric Time Dimension 'ds'
@@ -35,11 +42,11 @@ FROM (
FROM ***************************.fct_bookings bookings_source_src_28000
) subq_15
ON
- time_spine_src_28006.ds - INTERVAL 5 day = subq_15.metric_time__day
+ rss_28018_cte.ds__day - INTERVAL 5 day = subq_15.metric_time__day
GROUP BY
- time_spine_src_28006.ds
+ rss_28018_cte.ds__day
) subq_22
) subq_23
ON
- time_spine_src_28006.ds - INTERVAL 2 day = subq_23.metric_time__day
+ rss_28018_cte.ds__day - INTERVAL 2 day = subq_23.metric_time__day
) subq_27
diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0_optimized.sql
index 6a16e0902..2a5645535 100644
--- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0_optimized.sql
+++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0_optimized.sql
@@ -3,16 +3,23 @@ test_filename: test_derived_metric_rendering.py
sql_engine: DuckDB
---
-- Compute Metrics via Expressions
+WITH rss_28018_cte AS (
+ -- Read From Time Spine 'mf_time_spine'
+ SELECT
+ ds AS ds__day
+ FROM ***************************.mf_time_spine time_spine_src_28006
+)
+
SELECT
- metric_time__day
+ metric_time__day AS metric_time__day
, 2 * bookings_offset_once AS bookings_offset_twice
FROM (
-- Join to Time Spine Dataset
-- Constrain Time Range to [2020-01-12T00:00:00, 2020-01-13T00:00:00]
SELECT
- time_spine_src_28006.ds AS metric_time__day
+ rss_28018_cte.ds__day AS metric_time__day
, subq_24.bookings_offset_once AS bookings_offset_once
- FROM ***************************.mf_time_spine time_spine_src_28006
+ FROM rss_28018_cte rss_28018_cte
INNER JOIN (
-- Compute Metrics via Expressions
SELECT
@@ -24,9 +31,9 @@ FROM (
-- Aggregate Measures
-- Compute Metrics via Expressions
SELECT
- time_spine_src_28006.ds AS metric_time__day
+ rss_28018_cte.ds__day AS metric_time__day
, SUM(subq_16.bookings) AS bookings
- FROM ***************************.mf_time_spine time_spine_src_28006
+ FROM rss_28018_cte rss_28018_cte
INNER JOIN (
-- Read Elements From Semantic Model 'bookings_source'
-- Metric Time Dimension 'ds'
@@ -36,12 +43,12 @@ FROM (
FROM ***************************.fct_bookings bookings_source_src_28000
) subq_16
ON
- time_spine_src_28006.ds - INTERVAL 5 day = subq_16.metric_time__day
+ rss_28018_cte.ds__day - INTERVAL 5 day = subq_16.metric_time__day
GROUP BY
- time_spine_src_28006.ds
+ rss_28018_cte.ds__day
) subq_23
) subq_24
ON
- time_spine_src_28006.ds - INTERVAL 2 day = subq_24.metric_time__day
- WHERE time_spine_src_28006.ds BETWEEN '2020-01-12' AND '2020-01-13'
+ rss_28018_cte.ds__day - INTERVAL 2 day = subq_24.metric_time__day
+ WHERE rss_28018_cte.ds__day BETWEEN '2020-01-12' AND '2020-01-13'
) subq_29
diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0_optimized.sql
index c25d4f0b9..59b3664d7 100644
--- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0_optimized.sql
+++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0_optimized.sql
@@ -3,8 +3,15 @@ test_filename: test_derived_metric_rendering.py
sql_engine: DuckDB
---
-- Compute Metrics via Expressions
+WITH rss_28018_cte AS (
+ -- Read From Time Spine 'mf_time_spine'
+ SELECT
+ ds AS ds__day
+ FROM ***************************.mf_time_spine time_spine_src_28006
+)
+
SELECT
- metric_time__day
+ metric_time__day AS metric_time__day
, 2 * bookings_offset_once AS bookings_offset_twice
FROM (
-- Constrain Output with WHERE
@@ -14,9 +21,9 @@ FROM (
FROM (
-- Join to Time Spine Dataset
SELECT
- time_spine_src_28006.ds AS metric_time__day
+ rss_28018_cte.ds__day AS metric_time__day
, subq_24.bookings_offset_once AS bookings_offset_once
- FROM ***************************.mf_time_spine time_spine_src_28006
+ FROM rss_28018_cte rss_28018_cte
INNER JOIN (
-- Compute Metrics via Expressions
SELECT
@@ -28,9 +35,9 @@ FROM (
-- Aggregate Measures
-- Compute Metrics via Expressions
SELECT
- time_spine_src_28006.ds AS metric_time__day
+ rss_28018_cte.ds__day AS metric_time__day
, SUM(subq_16.bookings) AS bookings
- FROM ***************************.mf_time_spine time_spine_src_28006
+ FROM rss_28018_cte rss_28018_cte
INNER JOIN (
-- Read Elements From Semantic Model 'bookings_source'
-- Metric Time Dimension 'ds'
@@ -40,13 +47,13 @@ FROM (
FROM ***************************.fct_bookings bookings_source_src_28000
) subq_16
ON
- time_spine_src_28006.ds - INTERVAL 5 day = subq_16.metric_time__day
+ rss_28018_cte.ds__day - INTERVAL 5 day = subq_16.metric_time__day
GROUP BY
- time_spine_src_28006.ds
+ rss_28018_cte.ds__day
) subq_23
) subq_24
ON
- time_spine_src_28006.ds - INTERVAL 2 day = subq_24.metric_time__day
+ rss_28018_cte.ds__day - INTERVAL 2 day = subq_24.metric_time__day
) subq_28
WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13'
) subq_29
diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql
index 303e4e7ba..04ccd1522 100644
--- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql
+++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql
@@ -12,6 +12,13 @@ WITH sma_28009_cte AS (
FROM ***************************.fct_bookings bookings_source_src_28000
)
+, rss_28018_cte AS (
+ -- Read From Time Spine 'mf_time_spine'
+ SELECT
+ ds AS ds__day
+ FROM ***************************.mf_time_spine time_spine_src_28006
+)
+
SELECT
metric_time__day AS metric_time__day
, bookings_fill_nulls_with_0 - bookings_2_weeks_ago AS bookings_growth_2_weeks_fill_nulls_with_0_for_non_offset
@@ -29,9 +36,9 @@ FROM (
FROM (
-- Join to Time Spine Dataset
SELECT
- time_spine_src_28006.ds AS metric_time__day
+ rss_28018_cte.ds__day AS metric_time__day
, subq_22.bookings AS bookings
- FROM ***************************.mf_time_spine time_spine_src_28006
+ FROM rss_28018_cte rss_28018_cte
LEFT OUTER JOIN (
-- Read From CTE For node_id=sma_28009
-- Pass Only Elements: ['bookings', 'metric_time__day']
@@ -44,7 +51,7 @@ FROM (
metric_time__day
) subq_22
ON
- time_spine_src_28006.ds = subq_22.metric_time__day
+ rss_28018_cte.ds__day = subq_22.metric_time__day
) subq_26
) subq_27
FULL OUTER JOIN (
@@ -53,15 +60,15 @@ FROM (
-- Aggregate Measures
-- Compute Metrics via Expressions
SELECT
- time_spine_src_28006.ds AS metric_time__day
+ rss_28018_cte.ds__day AS metric_time__day
, SUM(sma_28009_cte.bookings) AS bookings_2_weeks_ago
- FROM ***************************.mf_time_spine time_spine_src_28006
+ FROM rss_28018_cte rss_28018_cte
INNER JOIN
sma_28009_cte sma_28009_cte
ON
- time_spine_src_28006.ds - INTERVAL 14 day = sma_28009_cte.metric_time__day
+ rss_28018_cte.ds__day - INTERVAL 14 day = sma_28009_cte.metric_time__day
GROUP BY
- time_spine_src_28006.ds
+ rss_28018_cte.ds__day
) subq_35
ON
subq_27.metric_time__day = subq_35.metric_time__day
diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/DuckDB/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/DuckDB/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql
index 6e7efd837..4c3453d4b 100644
--- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/DuckDB/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql
+++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlPlan/DuckDB/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql
@@ -27,6 +27,13 @@ WITH sma_28009_cte AS (
FROM ***************************.dim_listings_latest listings_latest_src_28000
)
+, rss_28018_cte AS (
+ -- Read From Time Spine 'mf_time_spine'
+ SELECT
+ ds AS ds__day
+ FROM ***************************.mf_time_spine time_spine_src_28006
+)
+
SELECT
metric_time__day AS metric_time__day
, listing__country_latest AS listing__country_latest
@@ -47,10 +54,10 @@ FROM (
FROM (
-- Join to Time Spine Dataset
SELECT
- time_spine_src_28006.ds AS metric_time__day
+ rss_28018_cte.ds__day AS metric_time__day
, subq_41.listing__country_latest AS listing__country_latest
, subq_41.bookings AS bookings
- FROM ***************************.mf_time_spine time_spine_src_28006
+ FROM rss_28018_cte rss_28018_cte
LEFT OUTER JOIN (
-- Constrain Output with WHERE
-- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day']
@@ -78,7 +85,7 @@ FROM (
, listing__country_latest
) subq_41
ON
- time_spine_src_28006.ds = subq_41.metric_time__day
+ rss_28018_cte.ds__day = subq_41.metric_time__day
) subq_45
) subq_46
FULL OUTER JOIN (
@@ -90,10 +97,10 @@ FROM (
FROM (
-- Join to Time Spine Dataset
SELECT
- time_spine_src_28006.ds AS metric_time__day
+ rss_28018_cte.ds__day AS metric_time__day
, subq_57.listing__country_latest AS listing__country_latest
, subq_57.bookings AS bookings
- FROM ***************************.mf_time_spine time_spine_src_28006
+ FROM rss_28018_cte rss_28018_cte
LEFT OUTER JOIN (
-- Constrain Output with WHERE
-- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day']
@@ -112,15 +119,15 @@ FROM (
FROM (
-- Join to Time Spine Dataset
SELECT
- time_spine_src_28006.ds AS metric_time__day
+ rss_28018_cte.ds__day AS metric_time__day
, sma_28009_cte.listing AS listing
, sma_28009_cte.booking__is_instant AS booking__is_instant
, sma_28009_cte.bookings AS bookings
- FROM ***************************.mf_time_spine time_spine_src_28006
+ FROM rss_28018_cte rss_28018_cte
INNER JOIN
sma_28009_cte sma_28009_cte
ON
- time_spine_src_28006.ds - INTERVAL 14 day = sma_28009_cte.metric_time__day
+ rss_28018_cte.ds__day - INTERVAL 14 day = sma_28009_cte.metric_time__day
) subq_51
LEFT OUTER JOIN
sma_28014_cte sma_28014_cte
@@ -133,7 +140,7 @@ FROM (
, listing__country_latest
) subq_57
ON
- time_spine_src_28006.ds = subq_57.metric_time__day
+ rss_28018_cte.ds__day = subq_57.metric_time__day
) subq_61
) subq_62
ON