From 228d4bb17168fe6b5faeb173d6727927e12f2a01 Mon Sep 17 00:00:00 2001 From: tlento Date: Tue, 3 Sep 2024 12:40:51 -0700 Subject: [PATCH] Update SQL engine snapshots --- ...timespine_and_fill_nulls_with_0__plan0.sql | 8 +++- ...and_fill_nulls_with_0__plan0_optimized.sql | 26 ++++++++++--- ...timespine_and_fill_nulls_with_0__plan0.sql | 8 +++- ...and_fill_nulls_with_0__plan0_optimized.sql | 26 ++++++++++--- ...timespine_and_fill_nulls_with_0__plan0.sql | 8 +++- ...and_fill_nulls_with_0__plan0_optimized.sql | 26 ++++++++++--- ...timespine_and_fill_nulls_with_0__plan0.sql | 8 +++- ...and_fill_nulls_with_0__plan0_optimized.sql | 26 ++++++++++--- ...timespine_and_fill_nulls_with_0__plan0.sql | 8 +++- ...and_fill_nulls_with_0__plan0_optimized.sql | 26 ++++++++++--- ...timespine_and_fill_nulls_with_0__plan0.sql | 8 +++- ...and_fill_nulls_with_0__plan0_optimized.sql | 26 ++++++++++--- ..._metric_with_non_default_grains__plan0.sql | 2 +- ...th_non_default_grains__plan0_optimized.sql | 2 +- ..._no_window_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 4 +- ...c_with_agg_time_and_metric_time__plan0.sql | 2 +- ..._time_and_metric_time__plan0_optimized.sql | 2 +- ..._metric_with_agg_time_dimension__plan0.sql | 4 +- ...th_agg_time_dimension__plan0_optimized.sql | 15 +++++-- ...th_multiple_agg_time_dimensions__plan0.sql | 2 +- ...e_agg_time_dimensions__plan0_optimized.sql | 2 +- ...multiple_metric_time_dimensions__plan0.sql | 2 +- ...etric_time_dimensions__plan0_optimized.sql | 2 +- ...with_non_adjustable_time_filter__plan0.sql | 4 +- ...djustable_time_filter__plan0_optimized.sql | 15 +++++-- ...e_metric_with_non_default_grain__plan0.sql | 2 +- ...ith_non_default_grain__plan0_optimized.sql | 2 +- ...ive_metric_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 4 +- ..._metric_with_non_default_grains__plan0.sql | 2 +- ...th_non_default_grains__plan0_optimized.sql | 2 +- ...e_metric_with_non_default_grain__plan0.sql | 2 +- ...ith_non_default_grain__plan0_optimized.sql | 2 +- ..._metric_with_non_default_grains__plan0.sql | 2 +- ...th_non_default_grains__plan0_optimized.sql | 2 +- ...w_metric_with_non_default_grain__plan0.sql | 2 +- ...ith_non_default_grain__plan0_optimized.sql | 2 +- ..._metric_with_non_default_grains__plan0.sql | 6 ++- ...th_non_default_grains__plan0_optimized.sql | 17 +++++--- ..._metric_with_non_default_grains__plan0.sql | 4 +- ...th_non_default_grains__plan0_optimized.sql | 4 +- ..._no_window_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 4 +- ...c_with_agg_time_and_metric_time__plan0.sql | 4 +- ..._time_and_metric_time__plan0_optimized.sql | 4 +- ..._metric_with_agg_time_dimension__plan0.sql | 4 +- ...th_agg_time_dimension__plan0_optimized.sql | 17 +++++--- ...th_multiple_agg_time_dimensions__plan0.sql | 4 +- ...e_agg_time_dimensions__plan0_optimized.sql | 4 +- ...multiple_metric_time_dimensions__plan0.sql | 4 +- ...etric_time_dimensions__plan0_optimized.sql | 4 +- ...with_non_adjustable_time_filter__plan0.sql | 4 +- ...djustable_time_filter__plan0_optimized.sql | 15 +++++-- ...e_metric_with_non_default_grain__plan0.sql | 4 +- ...ith_non_default_grain__plan0_optimized.sql | 4 +- ...ive_metric_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 4 +- ..._metric_with_non_default_grains__plan0.sql | 4 +- ...th_non_default_grains__plan0_optimized.sql | 4 +- ...e_metric_with_non_default_grain__plan0.sql | 4 +- ...ith_non_default_grain__plan0_optimized.sql | 4 +- ..._metric_with_non_default_grains__plan0.sql | 4 +- ...th_non_default_grains__plan0_optimized.sql | 4 +- ...w_metric_with_non_default_grain__plan0.sql | 4 +- ...ith_non_default_grain__plan0_optimized.sql | 4 +- ..._metric_with_non_default_grains__plan0.sql | 8 ++-- ...th_non_default_grains__plan0_optimized.sql | 19 ++++++--- ..._metric_with_non_default_grains__plan0.sql | 4 +- ...th_non_default_grains__plan0_optimized.sql | 4 +- ..._no_window_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 4 +- ...c_with_agg_time_and_metric_time__plan0.sql | 4 +- ..._time_and_metric_time__plan0_optimized.sql | 4 +- ..._metric_with_agg_time_dimension__plan0.sql | 4 +- ...th_agg_time_dimension__plan0_optimized.sql | 17 +++++--- ...th_multiple_agg_time_dimensions__plan0.sql | 4 +- ...e_agg_time_dimensions__plan0_optimized.sql | 4 +- ...multiple_metric_time_dimensions__plan0.sql | 4 +- ...etric_time_dimensions__plan0_optimized.sql | 4 +- ...with_non_adjustable_time_filter__plan0.sql | 4 +- ...djustable_time_filter__plan0_optimized.sql | 15 +++++-- ...e_metric_with_non_default_grain__plan0.sql | 4 +- ...ith_non_default_grain__plan0_optimized.sql | 4 +- ...ive_metric_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 4 +- ..._metric_with_non_default_grains__plan0.sql | 4 +- ...th_non_default_grains__plan0_optimized.sql | 4 +- ...e_metric_with_non_default_grain__plan0.sql | 4 +- ...ith_non_default_grain__plan0_optimized.sql | 4 +- ..._metric_with_non_default_grains__plan0.sql | 4 +- ...th_non_default_grains__plan0_optimized.sql | 4 +- ...w_metric_with_non_default_grain__plan0.sql | 4 +- ...ith_non_default_grain__plan0_optimized.sql | 4 +- ..._metric_with_non_default_grains__plan0.sql | 8 ++-- ...th_non_default_grains__plan0_optimized.sql | 19 ++++++--- ..._metric_with_non_default_grains__plan0.sql | 4 +- ...th_non_default_grains__plan0_optimized.sql | 4 +- ..._no_window_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 4 +- ...c_with_agg_time_and_metric_time__plan0.sql | 4 +- ..._time_and_metric_time__plan0_optimized.sql | 4 +- ..._metric_with_agg_time_dimension__plan0.sql | 4 +- ...th_agg_time_dimension__plan0_optimized.sql | 17 +++++--- ...th_multiple_agg_time_dimensions__plan0.sql | 4 +- ...e_agg_time_dimensions__plan0_optimized.sql | 4 +- ...multiple_metric_time_dimensions__plan0.sql | 4 +- ...etric_time_dimensions__plan0_optimized.sql | 4 +- ...with_non_adjustable_time_filter__plan0.sql | 4 +- ...djustable_time_filter__plan0_optimized.sql | 15 +++++-- ...e_metric_with_non_default_grain__plan0.sql | 4 +- ...ith_non_default_grain__plan0_optimized.sql | 4 +- ...ive_metric_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 4 +- ..._metric_with_non_default_grains__plan0.sql | 4 +- ...th_non_default_grains__plan0_optimized.sql | 4 +- ...e_metric_with_non_default_grain__plan0.sql | 4 +- ...ith_non_default_grain__plan0_optimized.sql | 4 +- ..._metric_with_non_default_grains__plan0.sql | 4 +- ...th_non_default_grains__plan0_optimized.sql | 4 +- ...w_metric_with_non_default_grain__plan0.sql | 4 +- ...ith_non_default_grain__plan0_optimized.sql | 4 +- ..._metric_with_non_default_grains__plan0.sql | 8 ++-- ...th_non_default_grains__plan0_optimized.sql | 19 ++++++--- ..._metric_with_non_default_grains__plan0.sql | 4 +- ...th_non_default_grains__plan0_optimized.sql | 4 +- ..._no_window_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 4 +- ...c_with_agg_time_and_metric_time__plan0.sql | 4 +- ..._time_and_metric_time__plan0_optimized.sql | 4 +- ..._metric_with_agg_time_dimension__plan0.sql | 4 +- ...th_agg_time_dimension__plan0_optimized.sql | 17 +++++--- ...th_multiple_agg_time_dimensions__plan0.sql | 4 +- ...e_agg_time_dimensions__plan0_optimized.sql | 4 +- ...multiple_metric_time_dimensions__plan0.sql | 4 +- ...etric_time_dimensions__plan0_optimized.sql | 4 +- ...with_non_adjustable_time_filter__plan0.sql | 4 +- ...djustable_time_filter__plan0_optimized.sql | 15 +++++-- ...e_metric_with_non_default_grain__plan0.sql | 4 +- ...ith_non_default_grain__plan0_optimized.sql | 4 +- ...ive_metric_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 4 +- ..._metric_with_non_default_grains__plan0.sql | 4 +- ...th_non_default_grains__plan0_optimized.sql | 4 +- ...e_metric_with_non_default_grain__plan0.sql | 4 +- ...ith_non_default_grain__plan0_optimized.sql | 4 +- ..._metric_with_non_default_grains__plan0.sql | 4 +- ...th_non_default_grains__plan0_optimized.sql | 4 +- ...w_metric_with_non_default_grain__plan0.sql | 4 +- ...ith_non_default_grain__plan0_optimized.sql | 4 +- ..._metric_with_non_default_grains__plan0.sql | 8 ++-- ...th_non_default_grains__plan0_optimized.sql | 19 ++++++--- ..._metric_with_non_default_grains__plan0.sql | 4 +- ...th_non_default_grains__plan0_optimized.sql | 4 +- ..._no_window_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 4 +- ...c_with_agg_time_and_metric_time__plan0.sql | 4 +- ..._time_and_metric_time__plan0_optimized.sql | 4 +- ..._metric_with_agg_time_dimension__plan0.sql | 4 +- ...th_agg_time_dimension__plan0_optimized.sql | 17 +++++--- ...th_multiple_agg_time_dimensions__plan0.sql | 4 +- ...e_agg_time_dimensions__plan0_optimized.sql | 4 +- ...multiple_metric_time_dimensions__plan0.sql | 4 +- ...etric_time_dimensions__plan0_optimized.sql | 4 +- ...with_non_adjustable_time_filter__plan0.sql | 4 +- ...djustable_time_filter__plan0_optimized.sql | 15 +++++-- ...e_metric_with_non_default_grain__plan0.sql | 4 +- ...ith_non_default_grain__plan0_optimized.sql | 4 +- ...ive_metric_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 4 +- ..._metric_with_non_default_grains__plan0.sql | 4 +- ...th_non_default_grains__plan0_optimized.sql | 4 +- ...e_metric_with_non_default_grain__plan0.sql | 4 +- ...ith_non_default_grain__plan0_optimized.sql | 4 +- ..._metric_with_non_default_grains__plan0.sql | 4 +- ...th_non_default_grains__plan0_optimized.sql | 4 +- ...w_metric_with_non_default_grain__plan0.sql | 4 +- ...ith_non_default_grain__plan0_optimized.sql | 4 +- ..._metric_with_non_default_grains__plan0.sql | 8 ++-- ...th_non_default_grains__plan0_optimized.sql | 19 ++++++--- ...spine_node_with_offset_to_grain__plan0.sql | 4 +- ..._with_offset_to_grain__plan0_optimized.sql | 4 +- ...e_spine_node_with_offset_window__plan0.sql | 4 +- ...de_with_offset_window__plan0_optimized.sql | 4 +- ..._time_spine_node_without_offset__plan0.sql | 4 +- ...e_node_without_offset__plan0_optimized.sql | 4 +- ...spine_node_with_offset_to_grain__plan0.sql | 4 +- ..._with_offset_to_grain__plan0_optimized.sql | 4 +- ...e_spine_node_with_offset_window__plan0.sql | 4 +- ...de_with_offset_window__plan0_optimized.sql | 4 +- ..._time_spine_node_without_offset__plan0.sql | 4 +- ...e_node_without_offset__plan0_optimized.sql | 4 +- ...spine_node_with_offset_to_grain__plan0.sql | 4 +- ..._with_offset_to_grain__plan0_optimized.sql | 4 +- ...e_spine_node_with_offset_window__plan0.sql | 4 +- ...de_with_offset_window__plan0_optimized.sql | 4 +- ..._time_spine_node_without_offset__plan0.sql | 4 +- ...e_node_without_offset__plan0_optimized.sql | 4 +- ...spine_node_with_offset_to_grain__plan0.sql | 4 +- ..._with_offset_to_grain__plan0_optimized.sql | 4 +- ...e_spine_node_with_offset_window__plan0.sql | 4 +- ...de_with_offset_window__plan0_optimized.sql | 4 +- ..._time_spine_node_without_offset__plan0.sql | 4 +- ...e_node_without_offset__plan0_optimized.sql | 4 +- ...spine_node_with_offset_to_grain__plan0.sql | 4 +- ..._with_offset_to_grain__plan0_optimized.sql | 4 +- ...e_spine_node_with_offset_window__plan0.sql | 4 +- ...de_with_offset_window__plan0_optimized.sql | 4 +- ..._time_spine_node_without_offset__plan0.sql | 4 +- ...e_node_without_offset__plan0_optimized.sql | 4 +- ...spine_node_with_offset_to_grain__plan0.sql | 4 +- ..._with_offset_to_grain__plan0_optimized.sql | 4 +- ...e_spine_node_with_offset_window__plan0.sql | 4 +- ...de_with_offset_window__plan0_optimized.sql | 4 +- ..._time_spine_node_without_offset__plan0.sql | 4 +- ...e_node_without_offset__plan0_optimized.sql | 4 +- ...set_metric_with_time_constraint__plan0.sql | 8 +++- ..._with_time_constraint__plan0_optimized.sql | 19 ++++++--- ...ved_metric_with_offset_to_grain__plan0.sql | 4 +- ..._with_offset_to_grain__plan0_optimized.sql | 13 +++++-- ...offset_to_grain_and_granularity__plan0.sql | 4 +- ...grain_and_granularity__plan0_optimized.sql | 15 +++++-- ...rived_metric_with_offset_window__plan0.sql | 4 +- ...ic_with_offset_window__plan0_optimized.sql | 13 +++++-- ...h_offset_window_and_granularity__plan0.sql | 4 +- ...indow_and_granularity__plan0_optimized.sql | 13 +++++-- ...fset_window_and_offset_to_grain__plan0.sql | 8 +++- ...w_and_offset_to_grain__plan0_optimized.sql | 26 ++++++++++--- ...offset_to_grain_and_granularity__plan0.sql | 8 +++- ...grain_and_granularity__plan0_optimized.sql | 28 +++++++++---- ...h_offset_window_and_time_filter__plan0.sql | 4 +- ...indow_and_time_filter__plan0_optimized.sql | 13 +++++-- ...erived_offset_cumulative_metric__plan0.sql | 8 +++- ...set_cumulative_metric__plan0_optimized.sql | 28 +++++++++---- ...offset_metric_with_agg_time_dim__plan0.sql | 4 +- ...ric_with_agg_time_dim__plan0_optimized.sql | 13 +++++-- ...et_metric_with_one_input_metric__plan0.sql | 4 +- ...with_one_input_metric__plan0_optimized.sql | 13 +++++-- ...d_where_constraint_not_selected__plan0.sql | 8 +++- ...nstraint_not_selected__plan0_optimized.sql | 26 ++++++++++--- ...h_offset_multiple_input_metrics__plan0.sql | 4 +- ...ultiple_input_metrics__plan0_optimized.sql | 13 +++++-- .../BigQuery/test_nested_offsets__plan0.sql | 8 +++- .../test_nested_offsets__plan0_optimized.sql | 26 ++++++++++--- ...ed_offsets_with_time_constraint__plan0.sql | 8 +++- ..._with_time_constraint__plan0_optimized.sql | 17 ++++++-- ...d_offsets_with_where_constraint__plan0.sql | 8 +++- ...with_where_constraint__plan0_optimized.sql | 26 ++++++++++--- ...ry_have_different_granularities__plan0.sql | 4 +- ...fferent_granularities__plan0_optimized.sql | 17 +++++--- ...n_metric_multiple_granularities__plan0.sql | 4 +- ...ultiple_granularities__plan0_optimized.sql | 17 +++++--- ...fset_to_grain_with_agg_time_dim__plan0.sql | 4 +- ...ain_with_agg_time_dim__plan0_optimized.sql | 13 +++++-- ...ry_have_different_granularities__plan0.sql | 4 +- ...fferent_granularities__plan0_optimized.sql | 15 +++++-- ...w_metric_multiple_granularities__plan0.sql | 4 +- ...ultiple_granularities__plan0_optimized.sql | 17 +++++--- ...offset_window_with_agg_time_dim__plan0.sql | 4 +- ...dow_with_agg_time_dim__plan0_optimized.sql | 13 +++++-- ...set_metric_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 4 +- ...set_metric_with_time_constraint__plan0.sql | 8 +++- ..._with_time_constraint__plan0_optimized.sql | 19 ++++++--- ...ved_metric_with_offset_to_grain__plan0.sql | 4 +- ..._with_offset_to_grain__plan0_optimized.sql | 15 +++++-- ...offset_to_grain_and_granularity__plan0.sql | 4 +- ...grain_and_granularity__plan0_optimized.sql | 17 +++++--- ...rived_metric_with_offset_window__plan0.sql | 4 +- ...ic_with_offset_window__plan0_optimized.sql | 15 +++++-- ...h_offset_window_and_granularity__plan0.sql | 4 +- ...indow_and_granularity__plan0_optimized.sql | 15 +++++-- ...fset_window_and_offset_to_grain__plan0.sql | 8 +++- ...w_and_offset_to_grain__plan0_optimized.sql | 30 ++++++++++---- ...offset_to_grain_and_granularity__plan0.sql | 8 +++- ...grain_and_granularity__plan0_optimized.sql | 32 ++++++++++----- ...h_offset_window_and_time_filter__plan0.sql | 4 +- ...indow_and_time_filter__plan0_optimized.sql | 13 +++++-- ...erived_offset_cumulative_metric__plan0.sql | 8 +++- ...set_cumulative_metric__plan0_optimized.sql | 30 ++++++++++---- ...offset_metric_with_agg_time_dim__plan0.sql | 4 +- ...ric_with_agg_time_dim__plan0_optimized.sql | 15 +++++-- ...et_metric_with_one_input_metric__plan0.sql | 4 +- ...with_one_input_metric__plan0_optimized.sql | 15 +++++-- ...d_where_constraint_not_selected__plan0.sql | 8 +++- ...nstraint_not_selected__plan0_optimized.sql | 28 +++++++++---- ...h_offset_multiple_input_metrics__plan0.sql | 4 +- ...ultiple_input_metrics__plan0_optimized.sql | 13 +++++-- .../Databricks/test_nested_offsets__plan0.sql | 8 +++- .../test_nested_offsets__plan0_optimized.sql | 28 +++++++++---- ...ed_offsets_with_time_constraint__plan0.sql | 8 +++- ..._with_time_constraint__plan0_optimized.sql | 19 ++++++--- ...d_offsets_with_where_constraint__plan0.sql | 8 +++- ...with_where_constraint__plan0_optimized.sql | 28 +++++++++---- ...ry_have_different_granularities__plan0.sql | 4 +- ...fferent_granularities__plan0_optimized.sql | 17 +++++--- ...n_metric_multiple_granularities__plan0.sql | 4 +- ...ultiple_granularities__plan0_optimized.sql | 23 +++++++---- ...fset_to_grain_with_agg_time_dim__plan0.sql | 4 +- ...ain_with_agg_time_dim__plan0_optimized.sql | 15 +++++-- ...ry_have_different_granularities__plan0.sql | 4 +- ...fferent_granularities__plan0_optimized.sql | 15 +++++-- ...w_metric_multiple_granularities__plan0.sql | 4 +- ...ultiple_granularities__plan0_optimized.sql | 23 +++++++---- ...offset_window_with_agg_time_dim__plan0.sql | 4 +- ...dow_with_agg_time_dim__plan0_optimized.sql | 15 +++++-- ...set_metric_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 4 +- ...set_metric_with_time_constraint__plan0.sql | 8 +++- ..._with_time_constraint__plan0_optimized.sql | 19 ++++++--- ...ved_metric_with_offset_to_grain__plan0.sql | 4 +- ..._with_offset_to_grain__plan0_optimized.sql | 15 +++++-- ...offset_to_grain_and_granularity__plan0.sql | 4 +- ...grain_and_granularity__plan0_optimized.sql | 17 +++++--- ...rived_metric_with_offset_window__plan0.sql | 4 +- ...ic_with_offset_window__plan0_optimized.sql | 15 +++++-- ...h_offset_window_and_granularity__plan0.sql | 4 +- ...indow_and_granularity__plan0_optimized.sql | 15 +++++-- ...fset_window_and_offset_to_grain__plan0.sql | 8 +++- ...w_and_offset_to_grain__plan0_optimized.sql | 30 ++++++++++---- ...offset_to_grain_and_granularity__plan0.sql | 8 +++- ...grain_and_granularity__plan0_optimized.sql | 32 ++++++++++----- ...h_offset_window_and_time_filter__plan0.sql | 4 +- ...indow_and_time_filter__plan0_optimized.sql | 13 +++++-- ...erived_offset_cumulative_metric__plan0.sql | 8 +++- ...set_cumulative_metric__plan0_optimized.sql | 30 ++++++++++---- ...offset_metric_with_agg_time_dim__plan0.sql | 4 +- ...ric_with_agg_time_dim__plan0_optimized.sql | 15 +++++-- ...et_metric_with_one_input_metric__plan0.sql | 4 +- ...with_one_input_metric__plan0_optimized.sql | 15 +++++-- ...d_where_constraint_not_selected__plan0.sql | 8 +++- ...nstraint_not_selected__plan0_optimized.sql | 28 +++++++++---- ...h_offset_multiple_input_metrics__plan0.sql | 4 +- ...ultiple_input_metrics__plan0_optimized.sql | 13 +++++-- .../Postgres/test_nested_offsets__plan0.sql | 8 +++- .../test_nested_offsets__plan0_optimized.sql | 28 +++++++++---- ...ed_offsets_with_time_constraint__plan0.sql | 8 +++- ..._with_time_constraint__plan0_optimized.sql | 19 ++++++--- ...d_offsets_with_where_constraint__plan0.sql | 8 +++- ...with_where_constraint__plan0_optimized.sql | 28 +++++++++---- ...ry_have_different_granularities__plan0.sql | 4 +- ...fferent_granularities__plan0_optimized.sql | 17 +++++--- ...n_metric_multiple_granularities__plan0.sql | 4 +- ...ultiple_granularities__plan0_optimized.sql | 23 +++++++---- ...fset_to_grain_with_agg_time_dim__plan0.sql | 4 +- ...ain_with_agg_time_dim__plan0_optimized.sql | 15 +++++-- ...ry_have_different_granularities__plan0.sql | 4 +- ...fferent_granularities__plan0_optimized.sql | 15 +++++-- ...w_metric_multiple_granularities__plan0.sql | 4 +- ...ultiple_granularities__plan0_optimized.sql | 23 +++++++---- ...offset_window_with_agg_time_dim__plan0.sql | 4 +- ...dow_with_agg_time_dim__plan0_optimized.sql | 15 +++++-- ...set_metric_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 4 +- ...set_metric_with_time_constraint__plan0.sql | 8 +++- ..._with_time_constraint__plan0_optimized.sql | 19 ++++++--- ...ved_metric_with_offset_to_grain__plan0.sql | 4 +- ..._with_offset_to_grain__plan0_optimized.sql | 15 +++++-- ...offset_to_grain_and_granularity__plan0.sql | 4 +- ...grain_and_granularity__plan0_optimized.sql | 17 +++++--- ...rived_metric_with_offset_window__plan0.sql | 4 +- ...ic_with_offset_window__plan0_optimized.sql | 15 +++++-- ...h_offset_window_and_granularity__plan0.sql | 4 +- ...indow_and_granularity__plan0_optimized.sql | 15 +++++-- ...fset_window_and_offset_to_grain__plan0.sql | 8 +++- ...w_and_offset_to_grain__plan0_optimized.sql | 30 ++++++++++---- ...offset_to_grain_and_granularity__plan0.sql | 8 +++- ...grain_and_granularity__plan0_optimized.sql | 32 ++++++++++----- ...h_offset_window_and_time_filter__plan0.sql | 4 +- ...indow_and_time_filter__plan0_optimized.sql | 13 +++++-- ...erived_offset_cumulative_metric__plan0.sql | 8 +++- ...set_cumulative_metric__plan0_optimized.sql | 30 ++++++++++---- ...offset_metric_with_agg_time_dim__plan0.sql | 4 +- ...ric_with_agg_time_dim__plan0_optimized.sql | 15 +++++-- ...et_metric_with_one_input_metric__plan0.sql | 4 +- ...with_one_input_metric__plan0_optimized.sql | 15 +++++-- ...d_where_constraint_not_selected__plan0.sql | 8 +++- ...nstraint_not_selected__plan0_optimized.sql | 28 +++++++++---- ...h_offset_multiple_input_metrics__plan0.sql | 4 +- ...ultiple_input_metrics__plan0_optimized.sql | 13 +++++-- .../Redshift/test_nested_offsets__plan0.sql | 8 +++- .../test_nested_offsets__plan0_optimized.sql | 28 +++++++++---- ...ed_offsets_with_time_constraint__plan0.sql | 8 +++- ..._with_time_constraint__plan0_optimized.sql | 19 ++++++--- ...d_offsets_with_where_constraint__plan0.sql | 8 +++- ...with_where_constraint__plan0_optimized.sql | 28 +++++++++---- ...ry_have_different_granularities__plan0.sql | 4 +- ...fferent_granularities__plan0_optimized.sql | 17 +++++--- ...n_metric_multiple_granularities__plan0.sql | 4 +- ...ultiple_granularities__plan0_optimized.sql | 23 +++++++---- ...fset_to_grain_with_agg_time_dim__plan0.sql | 4 +- ...ain_with_agg_time_dim__plan0_optimized.sql | 15 +++++-- ...ry_have_different_granularities__plan0.sql | 4 +- ...fferent_granularities__plan0_optimized.sql | 15 +++++-- ...w_metric_multiple_granularities__plan0.sql | 4 +- ...ultiple_granularities__plan0_optimized.sql | 23 +++++++---- ...offset_window_with_agg_time_dim__plan0.sql | 4 +- ...dow_with_agg_time_dim__plan0_optimized.sql | 15 +++++-- ...set_metric_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 4 +- ...set_metric_with_time_constraint__plan0.sql | 8 +++- ..._with_time_constraint__plan0_optimized.sql | 19 ++++++--- ...ved_metric_with_offset_to_grain__plan0.sql | 4 +- ..._with_offset_to_grain__plan0_optimized.sql | 15 +++++-- ...offset_to_grain_and_granularity__plan0.sql | 4 +- ...grain_and_granularity__plan0_optimized.sql | 17 +++++--- ...rived_metric_with_offset_window__plan0.sql | 4 +- ...ic_with_offset_window__plan0_optimized.sql | 15 +++++-- ...h_offset_window_and_granularity__plan0.sql | 4 +- ...indow_and_granularity__plan0_optimized.sql | 15 +++++-- ...fset_window_and_offset_to_grain__plan0.sql | 8 +++- ...w_and_offset_to_grain__plan0_optimized.sql | 30 ++++++++++---- ...offset_to_grain_and_granularity__plan0.sql | 8 +++- ...grain_and_granularity__plan0_optimized.sql | 32 ++++++++++----- ...h_offset_window_and_time_filter__plan0.sql | 4 +- ...indow_and_time_filter__plan0_optimized.sql | 13 +++++-- ...erived_offset_cumulative_metric__plan0.sql | 8 +++- ...set_cumulative_metric__plan0_optimized.sql | 30 ++++++++++---- ...offset_metric_with_agg_time_dim__plan0.sql | 4 +- ...ric_with_agg_time_dim__plan0_optimized.sql | 15 +++++-- ...et_metric_with_one_input_metric__plan0.sql | 4 +- ...with_one_input_metric__plan0_optimized.sql | 15 +++++-- ...d_where_constraint_not_selected__plan0.sql | 8 +++- ...nstraint_not_selected__plan0_optimized.sql | 28 +++++++++---- ...h_offset_multiple_input_metrics__plan0.sql | 4 +- ...ultiple_input_metrics__plan0_optimized.sql | 13 +++++-- .../Snowflake/test_nested_offsets__plan0.sql | 8 +++- .../test_nested_offsets__plan0_optimized.sql | 28 +++++++++---- ...ed_offsets_with_time_constraint__plan0.sql | 8 +++- ..._with_time_constraint__plan0_optimized.sql | 19 ++++++--- ...d_offsets_with_where_constraint__plan0.sql | 8 +++- ...with_where_constraint__plan0_optimized.sql | 28 +++++++++---- ...ry_have_different_granularities__plan0.sql | 4 +- ...fferent_granularities__plan0_optimized.sql | 17 +++++--- ...n_metric_multiple_granularities__plan0.sql | 4 +- ...ultiple_granularities__plan0_optimized.sql | 23 +++++++---- ...fset_to_grain_with_agg_time_dim__plan0.sql | 4 +- ...ain_with_agg_time_dim__plan0_optimized.sql | 15 +++++-- ...ry_have_different_granularities__plan0.sql | 4 +- ...fferent_granularities__plan0_optimized.sql | 15 +++++-- ...w_metric_multiple_granularities__plan0.sql | 4 +- ...ultiple_granularities__plan0_optimized.sql | 23 +++++++---- ...offset_window_with_agg_time_dim__plan0.sql | 4 +- ...dow_with_agg_time_dim__plan0_optimized.sql | 15 +++++-- ...set_metric_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 4 +- ...set_metric_with_time_constraint__plan0.sql | 8 +++- ..._with_time_constraint__plan0_optimized.sql | 19 ++++++--- ...ved_metric_with_offset_to_grain__plan0.sql | 4 +- ..._with_offset_to_grain__plan0_optimized.sql | 15 +++++-- ...offset_to_grain_and_granularity__plan0.sql | 4 +- ...grain_and_granularity__plan0_optimized.sql | 17 +++++--- ...rived_metric_with_offset_window__plan0.sql | 4 +- ...ic_with_offset_window__plan0_optimized.sql | 15 +++++-- ...h_offset_window_and_granularity__plan0.sql | 4 +- ...indow_and_granularity__plan0_optimized.sql | 15 +++++-- ...fset_window_and_offset_to_grain__plan0.sql | 8 +++- ...w_and_offset_to_grain__plan0_optimized.sql | 30 ++++++++++---- ...offset_to_grain_and_granularity__plan0.sql | 8 +++- ...grain_and_granularity__plan0_optimized.sql | 32 ++++++++++----- ...h_offset_window_and_time_filter__plan0.sql | 4 +- ...indow_and_time_filter__plan0_optimized.sql | 13 +++++-- ...erived_offset_cumulative_metric__plan0.sql | 8 +++- ...set_cumulative_metric__plan0_optimized.sql | 30 ++++++++++---- ...offset_metric_with_agg_time_dim__plan0.sql | 4 +- ...ric_with_agg_time_dim__plan0_optimized.sql | 15 +++++-- ...et_metric_with_one_input_metric__plan0.sql | 4 +- ...with_one_input_metric__plan0_optimized.sql | 15 +++++-- ...d_where_constraint_not_selected__plan0.sql | 8 +++- ...nstraint_not_selected__plan0_optimized.sql | 28 +++++++++---- ...h_offset_multiple_input_metrics__plan0.sql | 4 +- ...ultiple_input_metrics__plan0_optimized.sql | 13 +++++-- .../Trino/test_nested_offsets__plan0.sql | 8 +++- .../test_nested_offsets__plan0_optimized.sql | 28 +++++++++---- ...ed_offsets_with_time_constraint__plan0.sql | 8 +++- ..._with_time_constraint__plan0_optimized.sql | 19 ++++++--- ...d_offsets_with_where_constraint__plan0.sql | 8 +++- ...with_where_constraint__plan0_optimized.sql | 28 +++++++++---- ...ry_have_different_granularities__plan0.sql | 4 +- ...fferent_granularities__plan0_optimized.sql | 17 +++++--- ...n_metric_multiple_granularities__plan0.sql | 4 +- ...ultiple_granularities__plan0_optimized.sql | 23 +++++++---- ...fset_to_grain_with_agg_time_dim__plan0.sql | 4 +- ...ain_with_agg_time_dim__plan0_optimized.sql | 15 +++++-- ...ry_have_different_granularities__plan0.sql | 4 +- ...fferent_granularities__plan0_optimized.sql | 15 +++++-- ...w_metric_multiple_granularities__plan0.sql | 4 +- ...ultiple_granularities__plan0_optimized.sql | 23 +++++++---- ...offset_window_with_agg_time_dim__plan0.sql | 4 +- ...dow_with_agg_time_dim__plan0_optimized.sql | 15 +++++-- ...set_metric_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 4 +- .../test_cumulative_fill_nulls__plan0.sql | 8 +++- ...cumulative_fill_nulls__plan0_optimized.sql | 28 +++++++++---- ...fill_nulls_for_one_input_metric__plan0.sql | 8 +++- ..._for_one_input_metric__plan0_optimized.sql | 26 ++++++++++--- ...join_to_time_spine_with_filters__plan0.sql | 4 +- ...me_spine_with_filters__plan0_optimized.sql | 4 +- ...e_fill_nulls_with_0_metric_time__plan0.sql | 4 +- ...ls_with_0_metric_time__plan0_optimized.sql | 13 +++++-- .../test_cumulative_fill_nulls__plan0.sql | 8 +++- ...cumulative_fill_nulls__plan0_optimized.sql | 30 ++++++++++---- ...fill_nulls_for_one_input_metric__plan0.sql | 8 +++- ..._for_one_input_metric__plan0_optimized.sql | 28 +++++++++---- ...join_to_time_spine_with_filters__plan0.sql | 4 +- ...me_spine_with_filters__plan0_optimized.sql | 4 +- ...e_fill_nulls_with_0_metric_time__plan0.sql | 4 +- ...ls_with_0_metric_time__plan0_optimized.sql | 13 +++++-- .../test_cumulative_fill_nulls__plan0.sql | 8 +++- ...cumulative_fill_nulls__plan0_optimized.sql | 30 ++++++++++---- ...fill_nulls_for_one_input_metric__plan0.sql | 8 +++- ..._for_one_input_metric__plan0_optimized.sql | 28 +++++++++---- ...join_to_time_spine_with_filters__plan0.sql | 4 +- ...me_spine_with_filters__plan0_optimized.sql | 4 +- ...e_fill_nulls_with_0_metric_time__plan0.sql | 4 +- ...ls_with_0_metric_time__plan0_optimized.sql | 13 +++++-- .../test_cumulative_fill_nulls__plan0.sql | 8 +++- ...cumulative_fill_nulls__plan0_optimized.sql | 30 ++++++++++---- ...fill_nulls_for_one_input_metric__plan0.sql | 8 +++- ..._for_one_input_metric__plan0_optimized.sql | 28 +++++++++---- ...join_to_time_spine_with_filters__plan0.sql | 4 +- ...me_spine_with_filters__plan0_optimized.sql | 4 +- ...e_fill_nulls_with_0_metric_time__plan0.sql | 4 +- ...ls_with_0_metric_time__plan0_optimized.sql | 13 +++++-- .../test_cumulative_fill_nulls__plan0.sql | 8 +++- ...cumulative_fill_nulls__plan0_optimized.sql | 30 ++++++++++---- ...fill_nulls_for_one_input_metric__plan0.sql | 8 +++- ..._for_one_input_metric__plan0_optimized.sql | 28 +++++++++---- ...join_to_time_spine_with_filters__plan0.sql | 4 +- ...me_spine_with_filters__plan0_optimized.sql | 4 +- ...e_fill_nulls_with_0_metric_time__plan0.sql | 4 +- ...ls_with_0_metric_time__plan0_optimized.sql | 13 +++++-- .../test_cumulative_fill_nulls__plan0.sql | 8 +++- ...cumulative_fill_nulls__plan0_optimized.sql | 30 ++++++++++---- ...fill_nulls_for_one_input_metric__plan0.sql | 8 +++- ..._for_one_input_metric__plan0_optimized.sql | 28 +++++++++---- ...join_to_time_spine_with_filters__plan0.sql | 4 +- ...me_spine_with_filters__plan0_optimized.sql | 4 +- ...e_fill_nulls_with_0_metric_time__plan0.sql | 4 +- ...ls_with_0_metric_time__plan0_optimized.sql | 13 +++++-- ...st_offset_window_with_date_part__plan0.sql | 4 +- ...window_with_date_part__plan0_optimized.sql | 13 +++++-- ...cumulative_grain_to_date_metric__plan0.sql | 4 +- ..._grain_to_date_metric__plan0_optimized.sql | 15 +++++-- ...bdaily_cumulative_window_metric__plan0.sql | 4 +- ...ulative_window_metric__plan0_optimized.sql | 15 +++++-- ...ides_metric_default_granularity__plan0.sql | 4 +- ...c_default_granularity__plan0_optimized.sql | 13 +++++-- ...daily_join_to_time_spine_metric__plan0.sql | 4 +- ..._to_time_spine_metric__plan0_optimized.sql | 13 +++++-- ...subdaily_offset_to_grain_metric__plan0.sql | 4 +- ...ffset_to_grain_metric__plan0_optimized.sql | 13 +++++-- ...t_subdaily_offset_window_metric__plan0.sql | 4 +- ..._offset_window_metric__plan0_optimized.sql | 13 +++++-- ...ily_time_constraint_with_metric__plan0.sql | 4 +- ...onstraint_with_metric__plan0_optimized.sql | 4 +- ...st_offset_window_with_date_part__plan0.sql | 4 +- ...window_with_date_part__plan0_optimized.sql | 15 +++++-- ...cumulative_grain_to_date_metric__plan0.sql | 4 +- ..._grain_to_date_metric__plan0_optimized.sql | 17 +++++--- ...bdaily_cumulative_window_metric__plan0.sql | 4 +- ...ulative_window_metric__plan0_optimized.sql | 17 +++++--- ...ides_metric_default_granularity__plan0.sql | 4 +- ...c_default_granularity__plan0_optimized.sql | 13 +++++-- ...daily_join_to_time_spine_metric__plan0.sql | 4 +- ..._to_time_spine_metric__plan0_optimized.sql | 13 +++++-- ...subdaily_offset_to_grain_metric__plan0.sql | 4 +- ...ffset_to_grain_metric__plan0_optimized.sql | 15 +++++-- ...t_subdaily_offset_window_metric__plan0.sql | 4 +- ..._offset_window_metric__plan0_optimized.sql | 15 +++++-- ...ily_time_constraint_with_metric__plan0.sql | 4 +- ...onstraint_with_metric__plan0_optimized.sql | 4 +- ...st_offset_window_with_date_part__plan0.sql | 4 +- ...window_with_date_part__plan0_optimized.sql | 15 +++++-- ...cumulative_grain_to_date_metric__plan0.sql | 4 +- ..._grain_to_date_metric__plan0_optimized.sql | 17 +++++--- ...bdaily_cumulative_window_metric__plan0.sql | 4 +- ...ulative_window_metric__plan0_optimized.sql | 17 +++++--- ...ides_metric_default_granularity__plan0.sql | 4 +- ...c_default_granularity__plan0_optimized.sql | 13 +++++-- ...daily_join_to_time_spine_metric__plan0.sql | 4 +- ..._to_time_spine_metric__plan0_optimized.sql | 13 +++++-- ...subdaily_offset_to_grain_metric__plan0.sql | 4 +- ...ffset_to_grain_metric__plan0_optimized.sql | 15 +++++-- ...t_subdaily_offset_window_metric__plan0.sql | 4 +- ..._offset_window_metric__plan0_optimized.sql | 15 +++++-- ...ily_time_constraint_with_metric__plan0.sql | 4 +- ...onstraint_with_metric__plan0_optimized.sql | 4 +- ...st_offset_window_with_date_part__plan0.sql | 4 +- ...window_with_date_part__plan0_optimized.sql | 15 +++++-- ...cumulative_grain_to_date_metric__plan0.sql | 4 +- ..._grain_to_date_metric__plan0_optimized.sql | 17 +++++--- ...bdaily_cumulative_window_metric__plan0.sql | 4 +- ...ulative_window_metric__plan0_optimized.sql | 17 +++++--- ...ides_metric_default_granularity__plan0.sql | 4 +- ...c_default_granularity__plan0_optimized.sql | 13 +++++-- ...daily_join_to_time_spine_metric__plan0.sql | 4 +- ..._to_time_spine_metric__plan0_optimized.sql | 13 +++++-- ...subdaily_offset_to_grain_metric__plan0.sql | 4 +- ...ffset_to_grain_metric__plan0_optimized.sql | 15 +++++-- ...t_subdaily_offset_window_metric__plan0.sql | 4 +- ..._offset_window_metric__plan0_optimized.sql | 15 +++++-- ...ily_time_constraint_with_metric__plan0.sql | 4 +- ...onstraint_with_metric__plan0_optimized.sql | 4 +- ...st_offset_window_with_date_part__plan0.sql | 4 +- ...window_with_date_part__plan0_optimized.sql | 15 +++++-- ...cumulative_grain_to_date_metric__plan0.sql | 4 +- ..._grain_to_date_metric__plan0_optimized.sql | 17 +++++--- ...bdaily_cumulative_window_metric__plan0.sql | 4 +- ...ulative_window_metric__plan0_optimized.sql | 17 +++++--- ...ides_metric_default_granularity__plan0.sql | 4 +- ...c_default_granularity__plan0_optimized.sql | 13 +++++-- ...daily_join_to_time_spine_metric__plan0.sql | 4 +- ..._to_time_spine_metric__plan0_optimized.sql | 13 +++++-- ...subdaily_offset_to_grain_metric__plan0.sql | 4 +- ...ffset_to_grain_metric__plan0_optimized.sql | 15 +++++-- ...t_subdaily_offset_window_metric__plan0.sql | 4 +- ..._offset_window_metric__plan0_optimized.sql | 15 +++++-- ...ily_time_constraint_with_metric__plan0.sql | 4 +- ...onstraint_with_metric__plan0_optimized.sql | 4 +- ...st_offset_window_with_date_part__plan0.sql | 4 +- ...window_with_date_part__plan0_optimized.sql | 15 +++++-- ...cumulative_grain_to_date_metric__plan0.sql | 4 +- ..._grain_to_date_metric__plan0_optimized.sql | 17 +++++--- ...bdaily_cumulative_window_metric__plan0.sql | 4 +- ...ulative_window_metric__plan0_optimized.sql | 17 +++++--- ...ides_metric_default_granularity__plan0.sql | 4 +- ...c_default_granularity__plan0_optimized.sql | 13 +++++-- ...daily_join_to_time_spine_metric__plan0.sql | 4 +- ..._to_time_spine_metric__plan0_optimized.sql | 13 +++++-- ...subdaily_offset_to_grain_metric__plan0.sql | 4 +- ...ffset_to_grain_metric__plan0_optimized.sql | 15 +++++-- ...t_subdaily_offset_window_metric__plan0.sql | 4 +- ..._offset_window_metric__plan0_optimized.sql | 15 +++++-- ...ily_time_constraint_with_metric__plan0.sql | 4 +- ...onstraint_with_metric__plan0_optimized.sql | 4 +- ..._metric_with_query_time_filters__plan0.sql | 4 +- ...th_query_time_filters__plan0_optimized.sql | 15 +++++-- ...spine_metric_predicate_pushdown__plan0.sql | 12 ++++-- ...ic_predicate_pushdown__plan0_optimized.sql | 39 ++++++++++++++----- ..._metric_with_query_time_filters__plan0.sql | 4 +- ...th_query_time_filters__plan0_optimized.sql | 13 +++++-- ...ine_pushdown_filter_application__plan0.sql | 4 +- ...wn_filter_application__plan0_optimized.sql | 13 +++++-- ..._metric_with_query_time_filters__plan0.sql | 4 +- ...th_query_time_filters__plan0_optimized.sql | 15 +++++-- ...spine_metric_predicate_pushdown__plan0.sql | 12 ++++-- ...ic_predicate_pushdown__plan0_optimized.sql | 39 ++++++++++++++----- ..._metric_with_query_time_filters__plan0.sql | 4 +- ...th_query_time_filters__plan0_optimized.sql | 13 +++++-- ...ine_pushdown_filter_application__plan0.sql | 4 +- ...wn_filter_application__plan0_optimized.sql | 13 +++++-- ..._metric_with_query_time_filters__plan0.sql | 4 +- ...th_query_time_filters__plan0_optimized.sql | 15 +++++-- ...spine_metric_predicate_pushdown__plan0.sql | 12 ++++-- ...ic_predicate_pushdown__plan0_optimized.sql | 39 ++++++++++++++----- ..._metric_with_query_time_filters__plan0.sql | 4 +- ...th_query_time_filters__plan0_optimized.sql | 13 +++++-- ...ine_pushdown_filter_application__plan0.sql | 4 +- ...wn_filter_application__plan0_optimized.sql | 13 +++++-- ..._metric_with_query_time_filters__plan0.sql | 4 +- ...th_query_time_filters__plan0_optimized.sql | 15 +++++-- ...spine_metric_predicate_pushdown__plan0.sql | 12 ++++-- ...ic_predicate_pushdown__plan0_optimized.sql | 39 ++++++++++++++----- ..._metric_with_query_time_filters__plan0.sql | 4 +- ...th_query_time_filters__plan0_optimized.sql | 13 +++++-- ...ine_pushdown_filter_application__plan0.sql | 4 +- ...wn_filter_application__plan0_optimized.sql | 13 +++++-- ..._metric_with_query_time_filters__plan0.sql | 4 +- ...th_query_time_filters__plan0_optimized.sql | 15 +++++-- ...spine_metric_predicate_pushdown__plan0.sql | 12 ++++-- ...ic_predicate_pushdown__plan0_optimized.sql | 39 ++++++++++++++----- ..._metric_with_query_time_filters__plan0.sql | 4 +- ...th_query_time_filters__plan0_optimized.sql | 13 +++++-- ...ine_pushdown_filter_application__plan0.sql | 4 +- ...wn_filter_application__plan0_optimized.sql | 13 +++++-- ..._metric_with_query_time_filters__plan0.sql | 4 +- ...th_query_time_filters__plan0_optimized.sql | 15 +++++-- ...spine_metric_predicate_pushdown__plan0.sql | 12 ++++-- ...ic_predicate_pushdown__plan0_optimized.sql | 39 ++++++++++++++----- ..._metric_with_query_time_filters__plan0.sql | 4 +- ...th_query_time_filters__plan0_optimized.sql | 13 +++++-- ...ine_pushdown_filter_application__plan0.sql | 4 +- ...wn_filter_application__plan0_optimized.sql | 13 +++++-- ...ne_with_queried_time_constraint__plan0.sql | 4 +- ...eried_time_constraint__plan0_optimized.sql | 4 +- .../test_simple_join_to_time_spine__plan0.sql | 4 +- ...le_join_to_time_spine__plan0_optimized.sql | 13 +++++-- ..._join_to_time_spine_with_filter__plan0.sql | 4 +- ...ime_spine_with_filter__plan0_optimized.sql | 13 +++++-- ..._time_spine_with_queried_filter__plan0.sql | 4 +- ...e_with_queried_filter__plan0_optimized.sql | 13 +++++-- ...ne_with_queried_time_constraint__plan0.sql | 4 +- ...eried_time_constraint__plan0_optimized.sql | 4 +- .../test_simple_join_to_time_spine__plan0.sql | 4 +- ...le_join_to_time_spine__plan0_optimized.sql | 13 +++++-- ..._join_to_time_spine_with_filter__plan0.sql | 4 +- ...ime_spine_with_filter__plan0_optimized.sql | 13 +++++-- ..._time_spine_with_queried_filter__plan0.sql | 4 +- ...e_with_queried_filter__plan0_optimized.sql | 13 +++++-- ...ne_with_queried_time_constraint__plan0.sql | 4 +- ...eried_time_constraint__plan0_optimized.sql | 4 +- .../test_simple_join_to_time_spine__plan0.sql | 4 +- ...le_join_to_time_spine__plan0_optimized.sql | 13 +++++-- ..._join_to_time_spine_with_filter__plan0.sql | 4 +- ...ime_spine_with_filter__plan0_optimized.sql | 13 +++++-- ..._time_spine_with_queried_filter__plan0.sql | 4 +- ...e_with_queried_filter__plan0_optimized.sql | 13 +++++-- ...ne_with_queried_time_constraint__plan0.sql | 4 +- ...eried_time_constraint__plan0_optimized.sql | 4 +- .../test_simple_join_to_time_spine__plan0.sql | 4 +- ...le_join_to_time_spine__plan0_optimized.sql | 13 +++++-- ..._join_to_time_spine_with_filter__plan0.sql | 4 +- ...ime_spine_with_filter__plan0_optimized.sql | 13 +++++-- ..._time_spine_with_queried_filter__plan0.sql | 4 +- ...e_with_queried_filter__plan0_optimized.sql | 13 +++++-- ...ne_with_queried_time_constraint__plan0.sql | 4 +- ...eried_time_constraint__plan0_optimized.sql | 4 +- .../test_simple_join_to_time_spine__plan0.sql | 4 +- ...le_join_to_time_spine__plan0_optimized.sql | 13 +++++-- ..._join_to_time_spine_with_filter__plan0.sql | 4 +- ...ime_spine_with_filter__plan0_optimized.sql | 13 +++++-- ..._time_spine_with_queried_filter__plan0.sql | 4 +- ...e_with_queried_filter__plan0_optimized.sql | 13 +++++-- ...ne_with_queried_time_constraint__plan0.sql | 4 +- ...eried_time_constraint__plan0_optimized.sql | 4 +- .../test_simple_join_to_time_spine__plan0.sql | 4 +- ...le_join_to_time_spine__plan0_optimized.sql | 13 +++++-- ..._join_to_time_spine_with_filter__plan0.sql | 4 +- ...ime_spine_with_filter__plan0_optimized.sql | 13 +++++-- ..._time_spine_with_queried_filter__plan0.sql | 4 +- ...e_with_queried_filter__plan0_optimized.sql | 13 +++++-- 732 files changed, 5091 insertions(+), 1911 deletions(-) diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql index a0b4a9d875..f53e81b8db 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql @@ -16,8 +16,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATETIME_TRUNC(subq_5.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + metric_time__day ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures @@ -124,8 +126,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_18.ds AS metric_time__day + DATETIME_TRUNC(subq_18.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_18 + GROUP BY + metric_time__day ) subq_17 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql index 403fd7efdf..b74686bcd3 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/BigQuery/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql @@ -11,9 +11,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_26.ds AS metric_time__day + subq_25.metric_time__day AS metric_time__day , subq_24.visits AS visits - FROM ***************************.mf_time_spine subq_26 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_26 + GROUP BY + metric_time__day + ) subq_25 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -32,14 +39,21 @@ FROM ( metric_time__day ) subq_24 ON - subq_26.ds = subq_24.metric_time__day + subq_25.metric_time__day = subq_24.metric_time__day ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset SELECT - subq_39.ds AS metric_time__day + subq_38.metric_time__day AS metric_time__day , subq_37.buys AS buys - FROM ***************************.mf_time_spine subq_39 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_39 + GROUP BY + metric_time__day + ) subq_38 LEFT OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__day'] @@ -121,7 +135,7 @@ FROM ( metric_time__day ) subq_37 ON - subq_39.ds = subq_37.metric_time__day + subq_38.metric_time__day = subq_37.metric_time__day ) subq_40 ON subq_27.metric_time__day = subq_40.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql index 3f7a01455e..92f8602450 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql @@ -16,8 +16,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures @@ -124,8 +126,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_18.ds AS metric_time__day + DATE_TRUNC('day', subq_18.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', subq_18.ds) ) subq_17 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql index 9fe736bed1..a983d55a92 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Databricks/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql @@ -11,9 +11,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_26.ds AS metric_time__day + subq_25.metric_time__day AS metric_time__day , subq_24.visits AS visits - FROM ***************************.mf_time_spine subq_26 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_26 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_25 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -32,14 +39,21 @@ FROM ( metric_time__day ) subq_24 ON - subq_26.ds = subq_24.metric_time__day + subq_25.metric_time__day = subq_24.metric_time__day ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset SELECT - subq_39.ds AS metric_time__day + subq_38.metric_time__day AS metric_time__day , subq_37.buys AS buys - FROM ***************************.mf_time_spine subq_39 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_39 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_38 LEFT OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__day'] @@ -121,7 +135,7 @@ FROM ( metric_time__day ) subq_37 ON - subq_39.ds = subq_37.metric_time__day + subq_38.metric_time__day = subq_37.metric_time__day ) subq_40 ON subq_27.metric_time__day = subq_40.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql index 6d8cb2fbe9..0911adcd47 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql @@ -16,8 +16,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures @@ -124,8 +126,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_18.ds AS metric_time__day + DATE_TRUNC('day', subq_18.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', subq_18.ds) ) subq_17 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql index 9c23363737..d7c9981dd2 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Postgres/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql @@ -11,9 +11,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_26.ds AS metric_time__day + subq_25.metric_time__day AS metric_time__day , subq_24.visits AS visits - FROM ***************************.mf_time_spine subq_26 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_26 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_25 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -32,14 +39,21 @@ FROM ( metric_time__day ) subq_24 ON - subq_26.ds = subq_24.metric_time__day + subq_25.metric_time__day = subq_24.metric_time__day ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset SELECT - subq_39.ds AS metric_time__day + subq_38.metric_time__day AS metric_time__day , subq_37.buys AS buys - FROM ***************************.mf_time_spine subq_39 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_39 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_38 LEFT OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__day'] @@ -121,7 +135,7 @@ FROM ( metric_time__day ) subq_37 ON - subq_39.ds = subq_37.metric_time__day + subq_38.metric_time__day = subq_37.metric_time__day ) subq_40 ON subq_27.metric_time__day = subq_40.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql index bd4e2b5500..9a6552d921 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql @@ -16,8 +16,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures @@ -124,8 +126,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_18.ds AS metric_time__day + DATE_TRUNC('day', subq_18.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', subq_18.ds) ) subq_17 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql index ed74bb1db0..770c39bab7 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Redshift/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql @@ -11,9 +11,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_26.ds AS metric_time__day + subq_25.metric_time__day AS metric_time__day , subq_24.visits AS visits - FROM ***************************.mf_time_spine subq_26 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_26 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_25 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -32,14 +39,21 @@ FROM ( metric_time__day ) subq_24 ON - subq_26.ds = subq_24.metric_time__day + subq_25.metric_time__day = subq_24.metric_time__day ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset SELECT - subq_39.ds AS metric_time__day + subq_38.metric_time__day AS metric_time__day , subq_37.buys AS buys - FROM ***************************.mf_time_spine subq_39 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_39 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_38 LEFT OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__day'] @@ -121,7 +135,7 @@ FROM ( metric_time__day ) subq_37 ON - subq_39.ds = subq_37.metric_time__day + subq_38.metric_time__day = subq_37.metric_time__day ) subq_40 ON subq_27.metric_time__day = subq_40.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql index 4671508b46..1227c0a64a 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql @@ -16,8 +16,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures @@ -124,8 +126,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_18.ds AS metric_time__day + DATE_TRUNC('day', subq_18.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', subq_18.ds) ) subq_17 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql index c89c5b956d..fc6836e717 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Snowflake/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql @@ -11,9 +11,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_26.ds AS metric_time__day + subq_25.metric_time__day AS metric_time__day , subq_24.visits AS visits - FROM ***************************.mf_time_spine subq_26 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_26 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_25 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -32,14 +39,21 @@ FROM ( metric_time__day ) subq_24 ON - subq_26.ds = subq_24.metric_time__day + subq_25.metric_time__day = subq_24.metric_time__day ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset SELECT - subq_39.ds AS metric_time__day + subq_38.metric_time__day AS metric_time__day , subq_37.buys AS buys - FROM ***************************.mf_time_spine subq_39 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_39 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_38 LEFT OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__day'] @@ -121,7 +135,7 @@ FROM ( metric_time__day ) subq_37 ON - subq_39.ds = subq_37.metric_time__day + subq_38.metric_time__day = subq_37.metric_time__day ) subq_40 ON subq_27.metric_time__day = subq_40.metric_time__day diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql index 50363aa7e6..7c866a36fe 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.sql @@ -16,8 +16,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures @@ -124,8 +126,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_18.ds AS metric_time__day + DATE_TRUNC('day', subq_18.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', subq_18.ds) ) subq_17 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql index 6ba8de27ce..9e6357d655 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/Trino/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0_optimized.sql @@ -11,9 +11,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_26.ds AS metric_time__day + subq_25.metric_time__day AS metric_time__day , subq_24.visits AS visits - FROM ***************************.mf_time_spine subq_26 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_26 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_25 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -32,14 +39,21 @@ FROM ( metric_time__day ) subq_24 ON - subq_26.ds = subq_24.metric_time__day + subq_25.metric_time__day = subq_24.metric_time__day ) subq_27 FULL OUTER JOIN ( -- Join to Time Spine Dataset SELECT - subq_39.ds AS metric_time__day + subq_38.metric_time__day AS metric_time__day , subq_37.buys AS buys - FROM ***************************.mf_time_spine subq_39 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_39 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_38 LEFT OUTER JOIN ( -- Find conversions for user within the range of 7 day -- Pass Only Elements: ['buys', 'metric_time__day'] @@ -121,7 +135,7 @@ FROM ( metric_time__day ) subq_37 ON - subq_39.ds = subq_37.metric_time__day + subq_38.metric_time__day = subq_37.metric_time__day ) subq_40 ON subq_27.metric_time__day = subq_40.metric_time__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_all_time_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_all_time_metric_with_non_default_grains__plan0.sql index a2f0fe2a62..aa1031ff94 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_all_time_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_all_time_metric_with_non_default_grains__plan0.sql @@ -78,7 +78,7 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day , DATETIME_TRUNC(subq_3.ds, isoweek) AS metric_time__week , DATETIME_TRUNC(subq_3.ds, quarter) AS metric_time__quarter FROM ***************************.mf_time_spine subq_3 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_all_time_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_all_time_metric_with_non_default_grains__plan0_optimized.sql index b9a4fa76c0..b604945cae 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_all_time_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_all_time_metric_with_non_default_grains__plan0_optimized.sql @@ -28,7 +28,7 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATETIME_TRUNC(ds, day) AS metric_time__day , DATETIME_TRUNC(ds, isoweek) AS metric_time__week , DATETIME_TRUNC(ds, quarter) AS metric_time__quarter FROM ***************************.mf_time_spine subq_12 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 0659795b5c..e7b2adb729 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -59,9 +59,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_4.ds AS metric_time__day + DATETIME_TRUNC(subq_4.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_4 WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + metric_time__day ) subq_3 INNER JOIN ( -- Constrain Time Range to [2000-01-01T00:00:00, 2020-01-01T00:00:00] diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index a8dadf176f..59f2f8e058 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -9,9 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATETIME_TRUNC(ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + metric_time__day ) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql index 83ccdafc37..e7eb51fe8e 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql @@ -58,7 +58,7 @@ FROM ( -- Time Spine SELECT DATETIME_TRUNC(subq_3.ds, month) AS revenue_instance__ds__month - , subq_3.ds AS metric_time__day + , DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_3 GROUP BY revenue_instance__ds__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql index 35a428887f..314c2171cd 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( -- Time Spine SELECT DATETIME_TRUNC(ds, month) AS revenue_instance__ds__month - , ds AS metric_time__day + , DATETIME_TRUNC(ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_10 GROUP BY revenue_instance__ds__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_dimension__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_dimension__plan0.sql index 67fa8d1d50..bb845ef83e 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_dimension__plan0.sql @@ -54,8 +54,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS revenue_instance__ds__day + DATETIME_TRUNC(subq_3.ds, day) AS revenue_instance__ds__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + revenue_instance__ds__day ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql index 8589fc64c5..292477cf70 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql @@ -3,16 +3,23 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ds AS revenue_instance__ds__day + subq_9.revenue_instance__ds__day AS revenue_instance__ds__day , SUM(revenue_src_28000.revenue) AS trailing_2_months_revenue -FROM ***************************.mf_time_spine subq_10 +FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS revenue_instance__ds__day + FROM ***************************.mf_time_spine subq_10 + GROUP BY + revenue_instance__ds__day +) subq_9 INNER JOIN ***************************.fct_revenue revenue_src_28000 ON ( - DATETIME_TRUNC(revenue_src_28000.created_at, day) <= subq_10.ds + DATETIME_TRUNC(revenue_src_28000.created_at, day) <= subq_9.revenue_instance__ds__day ) AND ( - DATETIME_TRUNC(revenue_src_28000.created_at, day) > DATE_SUB(CAST(subq_10.ds AS DATETIME), INTERVAL 2 month) + DATETIME_TRUNC(revenue_src_28000.created_at, day) > DATE_SUB(CAST(subq_9.revenue_instance__ds__day AS DATETIME), INTERVAL 2 month) ) GROUP BY revenue_instance__ds__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql index c068c9dc98..9d231d1fbd 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql @@ -57,7 +57,7 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS revenue_instance__ds__day + DATETIME_TRUNC(subq_3.ds, day) AS revenue_instance__ds__day , DATETIME_TRUNC(subq_3.ds, month) AS revenue_instance__ds__month FROM ***************************.mf_time_spine subq_3 GROUP BY diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql index 890e5a2d78..893aa3175b 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql @@ -9,7 +9,7 @@ SELECT FROM ( -- Time Spine SELECT - ds AS revenue_instance__ds__day + DATETIME_TRUNC(ds, day) AS revenue_instance__ds__day , DATETIME_TRUNC(ds, month) AS revenue_instance__ds__month FROM ***************************.mf_time_spine subq_10 GROUP BY diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql index caddda4623..f72e302df7 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql @@ -57,7 +57,7 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day , DATETIME_TRUNC(subq_3.ds, month) AS metric_time__month FROM ***************************.mf_time_spine subq_3 GROUP BY diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql index bfbdc21801..2f64746747 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql @@ -9,7 +9,7 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATETIME_TRUNC(ds, day) AS metric_time__day , DATETIME_TRUNC(ds, month) AS metric_time__month FROM ***************************.mf_time_spine subq_10 GROUP BY diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql index aaa5f4c03b..dcc3d483da 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql @@ -121,8 +121,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + metric_time__day ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql index eed113f868..44572b6de2 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql @@ -8,16 +8,23 @@ FROM ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_11.ds AS metric_time__day + subq_10.metric_time__day AS metric_time__day , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_11 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_11 + GROUP BY + metric_time__day + ) subq_10 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATETIME_TRUNC(bookings_source_src_28000.ds, day) <= subq_11.ds + DATETIME_TRUNC(bookings_source_src_28000.ds, day) <= subq_10.metric_time__day ) AND ( - DATETIME_TRUNC(bookings_source_src_28000.ds, day) > DATE_SUB(CAST(subq_11.ds AS DATETIME), INTERVAL 2 day) + DATETIME_TRUNC(bookings_source_src_28000.ds, day) > DATE_SUB(CAST(subq_10.metric_time__day AS DATETIME), INTERVAL 2 day) ) ) subq_13 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_default_grain__plan0.sql index d3e05331c4..475977ac9e 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_default_grain__plan0.sql @@ -71,7 +71,7 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day , DATETIME_TRUNC(subq_3.ds, isoweek) AS metric_time__week FROM ***************************.mf_time_spine subq_3 GROUP BY diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql index 33aac00a24..cfafa40088 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql @@ -23,7 +23,7 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATETIME_TRUNC(ds, day) AS metric_time__day , DATETIME_TRUNC(ds, isoweek) AS metric_time__week FROM ***************************.mf_time_spine subq_12 GROUP BY diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql index 0fb334ddbe..e4950bccfe 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql @@ -59,9 +59,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_4.ds AS metric_time__day + DATETIME_TRUNC(subq_4.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_4 WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + metric_time__day ) subq_3 INNER JOIN ( -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 88ef795b84..d310463ad5 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -9,9 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATETIME_TRUNC(ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + metric_time__day ) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_cumulative_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_cumulative_metric_with_non_default_grains__plan0.sql index a216c5d3ef..7a569c4944 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_cumulative_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_cumulative_metric_with_non_default_grains__plan0.sql @@ -72,7 +72,7 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day , DATETIME_TRUNC(subq_3.ds, isoweek) AS metric_time__week FROM ***************************.mf_time_spine subq_3 GROUP BY diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql index 8ceaaa47ac..807bc5cdf7 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql @@ -24,7 +24,7 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATETIME_TRUNC(ds, day) AS metric_time__day , DATETIME_TRUNC(ds, isoweek) AS metric_time__week FROM ***************************.mf_time_spine subq_13 GROUP BY diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_grain_to_date_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_grain_to_date_metric_with_non_default_grain__plan0.sql index 63d46c0285..ad75ddd628 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_grain_to_date_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_grain_to_date_metric_with_non_default_grain__plan0.sql @@ -71,7 +71,7 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day , DATETIME_TRUNC(subq_3.ds, month) AS metric_time__month FROM ***************************.mf_time_spine subq_3 GROUP BY diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql index 93e1a59663..74542bbb2b 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql @@ -23,7 +23,7 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATETIME_TRUNC(ds, day) AS metric_time__day , DATETIME_TRUNC(ds, month) AS metric_time__month FROM ***************************.mf_time_spine subq_12 GROUP BY diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_grain_to_date_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_grain_to_date_metric_with_non_default_grains__plan0.sql index 51ffc30cdd..30a9019a94 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_grain_to_date_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_grain_to_date_metric_with_non_default_grains__plan0.sql @@ -80,7 +80,7 @@ FROM ( SELECT DATETIME_TRUNC(subq_3.ds, quarter) AS revenue_instance__ds__quarter , DATETIME_TRUNC(subq_3.ds, year) AS revenue_instance__ds__year - , subq_3.ds AS metric_time__day + , DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_3 GROUP BY revenue_instance__ds__quarter diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql index 0c9bfbbc88..c54efff16d 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql @@ -30,7 +30,7 @@ FROM ( SELECT DATETIME_TRUNC(ds, quarter) AS revenue_instance__ds__quarter , DATETIME_TRUNC(ds, year) AS revenue_instance__ds__year - , ds AS metric_time__day + , DATETIME_TRUNC(ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_12 GROUP BY revenue_instance__ds__quarter diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_window_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_window_metric_with_non_default_grain__plan0.sql index b0558dd480..217b70afba 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_window_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_window_metric_with_non_default_grain__plan0.sql @@ -67,7 +67,7 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day , DATETIME_TRUNC(subq_3.ds, year) AS metric_time__year FROM ***************************.mf_time_spine subq_3 GROUP BY diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_window_metric_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_window_metric_with_non_default_grain__plan0_optimized.sql index c1bbe03265..c03d9c784f 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_window_metric_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_window_metric_with_non_default_grain__plan0_optimized.sql @@ -19,7 +19,7 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATETIME_TRUNC(ds, day) AS metric_time__day , DATETIME_TRUNC(ds, year) AS metric_time__year FROM ***************************.mf_time_spine subq_12 GROUP BY diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_window_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_window_metric_with_non_default_grains__plan0.sql index 3359122720..a160b26d1c 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_window_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_window_metric_with_non_default_grains__plan0.sql @@ -32,8 +32,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATETIME_TRUNC(subq_8.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + metric_time__day ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures @@ -154,7 +156,7 @@ FROM ( -- Time Spine SELECT DATETIME_TRUNC(subq_3.ds, month) AS booking__ds__month - , subq_3.ds AS metric_time__day + , DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day , DATETIME_TRUNC(subq_3.ds, isoweek) AS metric_time__week FROM ***************************.mf_time_spine subq_3 GROUP BY diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_window_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_window_metric_with_non_default_grains__plan0_optimized.sql index 165b5a6198..8251ca4dd3 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_window_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/BigQuery/test_window_metric_with_non_default_grains__plan0_optimized.sql @@ -19,11 +19,18 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_20.ds AS metric_time__day - , DATETIME_TRUNC(subq_20.ds, isoweek) AS metric_time__week + subq_19.metric_time__day AS metric_time__day + , DATETIME_TRUNC(subq_19.metric_time__day, isoweek) AS metric_time__week , subq_18.booking__ds__month AS booking__ds__month , subq_18.bookers AS bookers - FROM ***************************.mf_time_spine subq_20 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + GROUP BY + metric_time__day + ) subq_19 LEFT OUTER JOIN ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__week', 'booking__ds__month', 'metric_time__day'] @@ -37,7 +44,7 @@ FROM ( -- Time Spine SELECT DATETIME_TRUNC(ds, month) AS booking__ds__month - , ds AS metric_time__day + , DATETIME_TRUNC(ds, day) AS metric_time__day , DATETIME_TRUNC(ds, isoweek) AS metric_time__week FROM ***************************.mf_time_spine subq_15 GROUP BY @@ -59,7 +66,7 @@ FROM ( , metric_time__week ) subq_18 ON - subq_20.ds = subq_18.metric_time__day + subq_19.metric_time__day = subq_18.metric_time__day ) subq_21 ) subq_23 GROUP BY diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_all_time_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_all_time_metric_with_non_default_grains__plan0.sql index 0638629bfb..6a461f4a1c 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_all_time_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_all_time_metric_with_non_default_grains__plan0.sql @@ -78,12 +78,12 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week , DATE_TRUNC('quarter', subq_3.ds) AS metric_time__quarter FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) , DATE_TRUNC('quarter', subq_3.ds) ) subq_2 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_all_time_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_all_time_metric_with_non_default_grains__plan0_optimized.sql index ea37c15884..818f885944 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_all_time_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_all_time_metric_with_non_default_grains__plan0_optimized.sql @@ -28,12 +28,12 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week , DATE_TRUNC('quarter', ds) AS metric_time__quarter FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) , DATE_TRUNC('quarter', ds) ) subq_11 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index ba616b7c75..2ab7352651 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -59,9 +59,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_4.ds AS metric_time__day + DATE_TRUNC('day', subq_4.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_4 WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + DATE_TRUNC('day', subq_4.ds) ) subq_3 INNER JOIN ( -- Constrain Time Range to [2000-01-01T00:00:00, 2020-01-01T00:00:00] diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index 0c658869b2..8a451ec0e0 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -9,9 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql index 22de7b52c0..c29fa08327 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql @@ -58,11 +58,11 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', subq_3.ds) AS revenue_instance__ds__month - , subq_3.ds AS metric_time__day + , DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 GROUP BY DATE_TRUNC('month', subq_3.ds) - , subq_3.ds + , DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql index af273a6d27..f5d971cc7d 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql @@ -10,11 +10,11 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS revenue_instance__ds__month - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 GROUP BY DATE_TRUNC('month', ds) - , ds + , DATE_TRUNC('day', ds) ) subq_9 INNER JOIN ***************************.fct_revenue revenue_src_28000 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_dimension__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_dimension__plan0.sql index 61ab896058..1eee6760d6 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_dimension__plan0.sql @@ -54,8 +54,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS revenue_instance__ds__day + DATE_TRUNC('day', subq_3.ds) AS revenue_instance__ds__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql index 6fc2ff41b0..e4b2eaa54a 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql @@ -3,16 +3,23 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ds AS revenue_instance__ds__day + subq_9.revenue_instance__ds__day AS revenue_instance__ds__day , SUM(revenue_src_28000.revenue) AS trailing_2_months_revenue -FROM ***************************.mf_time_spine subq_10 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS revenue_instance__ds__day + FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', ds) +) subq_9 INNER JOIN ***************************.fct_revenue revenue_src_28000 ON ( - DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_10.ds + DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_9.revenue_instance__ds__day ) AND ( - DATE_TRUNC('day', revenue_src_28000.created_at) > DATEADD(month, -2, subq_10.ds) + DATE_TRUNC('day', revenue_src_28000.created_at) > DATEADD(month, -2, subq_9.revenue_instance__ds__day) ) GROUP BY - subq_10.ds + subq_9.revenue_instance__ds__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql index abb3344a26..d313f1bdae 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql @@ -57,11 +57,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS revenue_instance__ds__day + DATE_TRUNC('day', subq_3.ds) AS revenue_instance__ds__day , DATE_TRUNC('month', subq_3.ds) AS revenue_instance__ds__month FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('month', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql index 6caf616294..118587c14d 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql @@ -9,11 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS revenue_instance__ds__day + DATE_TRUNC('day', ds) AS revenue_instance__ds__day , DATE_TRUNC('month', ds) AS revenue_instance__ds__month FROM ***************************.mf_time_spine subq_10 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('month', ds) ) subq_9 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql index 48ebb94d10..4ea8caf954 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql @@ -57,11 +57,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('month', subq_3.ds) AS metric_time__month FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('month', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql index 793cd64067..e6c9764b86 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql @@ -9,11 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month FROM ***************************.mf_time_spine subq_10 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('month', ds) ) subq_9 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql index 867b8e2db7..28b212ebd1 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql @@ -121,8 +121,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql index 2d6dabcdb2..d77ed07949 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql @@ -8,16 +8,23 @@ FROM ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_11.ds AS metric_time__day + subq_10.metric_time__day AS metric_time__day , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_10 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_11.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_10.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_11.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_10.metric_time__day) ) ) subq_13 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_default_grain__plan0.sql index 183461ce6a..e3bf1dd352 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_default_grain__plan0.sql @@ -71,11 +71,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql index 2b6f12b36c..88c6b1d789 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql @@ -23,11 +23,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) ) subq_11 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql index d8233fe4a6..e7fc27eae3 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql @@ -59,9 +59,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_4.ds AS metric_time__day + DATE_TRUNC('day', subq_4.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_4 WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + DATE_TRUNC('day', subq_4.ds) ) subq_3 INNER JOIN ( -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index cd4811e1ab..7686e4afa2 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -9,9 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_cumulative_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_cumulative_metric_with_non_default_grains__plan0.sql index f3f9badc38..611cd4ccc2 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_cumulative_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_cumulative_metric_with_non_default_grains__plan0.sql @@ -72,11 +72,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql index 94d66c8da0..94b62d19a4 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql @@ -24,11 +24,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week FROM ***************************.mf_time_spine subq_13 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) ) subq_12 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_grain_to_date_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_grain_to_date_metric_with_non_default_grain__plan0.sql index 15f75c76cd..ec07a89c18 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_grain_to_date_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_grain_to_date_metric_with_non_default_grain__plan0.sql @@ -71,11 +71,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('month', subq_3.ds) AS metric_time__month FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('month', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql index 0a70199c86..f85735034b 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql @@ -23,11 +23,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('month', ds) ) subq_11 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_grain_to_date_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_grain_to_date_metric_with_non_default_grains__plan0.sql index 5318ca0d14..034692983f 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_grain_to_date_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_grain_to_date_metric_with_non_default_grains__plan0.sql @@ -80,12 +80,12 @@ FROM ( SELECT DATE_TRUNC('quarter', subq_3.ds) AS revenue_instance__ds__quarter , DATE_TRUNC('year', subq_3.ds) AS revenue_instance__ds__year - , subq_3.ds AS metric_time__day + , DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 GROUP BY DATE_TRUNC('quarter', subq_3.ds) , DATE_TRUNC('year', subq_3.ds) - , subq_3.ds + , DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql index 8f10523e66..b087e7f9fb 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql @@ -30,12 +30,12 @@ FROM ( SELECT DATE_TRUNC('quarter', ds) AS revenue_instance__ds__quarter , DATE_TRUNC('year', ds) AS revenue_instance__ds__year - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_12 GROUP BY DATE_TRUNC('quarter', ds) , DATE_TRUNC('year', ds) - , ds + , DATE_TRUNC('day', ds) ) subq_11 INNER JOIN ***************************.fct_revenue revenue_src_28000 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_window_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_window_metric_with_non_default_grain__plan0.sql index 1b608ce209..f1303f8739 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_window_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_window_metric_with_non_default_grain__plan0.sql @@ -67,11 +67,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('year', subq_3.ds) AS metric_time__year FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('year', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_window_metric_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_window_metric_with_non_default_grain__plan0_optimized.sql index f2214f335f..0a69472e63 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_window_metric_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_window_metric_with_non_default_grain__plan0_optimized.sql @@ -19,11 +19,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('year', ds) AS metric_time__year FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('year', ds) ) subq_11 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_window_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_window_metric_with_non_default_grains__plan0.sql index 71573a57be..c2a8db591e 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_window_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_window_metric_with_non_default_grains__plan0.sql @@ -32,8 +32,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures @@ -154,12 +156,12 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', subq_3.ds) AS booking__ds__month - , subq_3.ds AS metric_time__day + , DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week FROM ***************************.mf_time_spine subq_3 GROUP BY DATE_TRUNC('month', subq_3.ds) - , subq_3.ds + , DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_window_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_window_metric_with_non_default_grains__plan0_optimized.sql index 40268062b2..eb798e6691 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_window_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Databricks/test_window_metric_with_non_default_grains__plan0_optimized.sql @@ -19,11 +19,18 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_20.ds AS metric_time__day - , DATE_TRUNC('week', subq_20.ds) AS metric_time__week + subq_19.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_19.metric_time__day) AS metric_time__week , subq_18.booking__ds__month AS booking__ds__month , subq_18.bookers AS bookers - FROM ***************************.mf_time_spine subq_20 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_19 LEFT OUTER JOIN ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__week', 'booking__ds__month', 'metric_time__day'] @@ -37,12 +44,12 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS booking__ds__month - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week FROM ***************************.mf_time_spine subq_15 GROUP BY DATE_TRUNC('month', ds) - , ds + , DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) ) subq_14 INNER JOIN @@ -59,7 +66,7 @@ FROM ( , subq_14.metric_time__week ) subq_18 ON - subq_20.ds = subq_18.metric_time__day + subq_19.metric_time__day = subq_18.metric_time__day ) subq_21 ) subq_23 GROUP BY diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_all_time_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_all_time_metric_with_non_default_grains__plan0.sql index 417d11e301..0b8e02798e 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_all_time_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_all_time_metric_with_non_default_grains__plan0.sql @@ -78,12 +78,12 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week , DATE_TRUNC('quarter', subq_3.ds) AS metric_time__quarter FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) , DATE_TRUNC('quarter', subq_3.ds) ) subq_2 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_all_time_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_all_time_metric_with_non_default_grains__plan0_optimized.sql index ea37c15884..818f885944 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_all_time_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_all_time_metric_with_non_default_grains__plan0_optimized.sql @@ -28,12 +28,12 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week , DATE_TRUNC('quarter', ds) AS metric_time__quarter FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) , DATE_TRUNC('quarter', ds) ) subq_11 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 8af29da836..3210cbab63 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -59,9 +59,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_4.ds AS metric_time__day + DATE_TRUNC('day', subq_4.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_4 WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + DATE_TRUNC('day', subq_4.ds) ) subq_3 INNER JOIN ( -- Constrain Time Range to [2000-01-01T00:00:00, 2020-01-01T00:00:00] diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index 0c658869b2..8a451ec0e0 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -9,9 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql index 203f1ddd3d..ab81db5983 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql @@ -58,11 +58,11 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', subq_3.ds) AS revenue_instance__ds__month - , subq_3.ds AS metric_time__day + , DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 GROUP BY DATE_TRUNC('month', subq_3.ds) - , subq_3.ds + , DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql index f00cf20a1b..408c2a9e1a 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql @@ -10,11 +10,11 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS revenue_instance__ds__month - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 GROUP BY DATE_TRUNC('month', ds) - , ds + , DATE_TRUNC('day', ds) ) subq_9 INNER JOIN ***************************.fct_revenue revenue_src_28000 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_dimension__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_dimension__plan0.sql index 193901038d..50bc877aed 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_dimension__plan0.sql @@ -54,8 +54,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS revenue_instance__ds__day + DATE_TRUNC('day', subq_3.ds) AS revenue_instance__ds__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql index 5754f68089..7fdfd40c91 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql @@ -3,16 +3,23 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ds AS revenue_instance__ds__day + subq_9.revenue_instance__ds__day AS revenue_instance__ds__day , SUM(revenue_src_28000.revenue) AS trailing_2_months_revenue -FROM ***************************.mf_time_spine subq_10 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS revenue_instance__ds__day + FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', ds) +) subq_9 INNER JOIN ***************************.fct_revenue revenue_src_28000 ON ( - DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_10.ds + DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_9.revenue_instance__ds__day ) AND ( - DATE_TRUNC('day', revenue_src_28000.created_at) > subq_10.ds - MAKE_INTERVAL(months => 2) + DATE_TRUNC('day', revenue_src_28000.created_at) > subq_9.revenue_instance__ds__day - MAKE_INTERVAL(months => 2) ) GROUP BY - subq_10.ds + subq_9.revenue_instance__ds__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql index 443cc1255e..b3516d1402 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql @@ -57,11 +57,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS revenue_instance__ds__day + DATE_TRUNC('day', subq_3.ds) AS revenue_instance__ds__day , DATE_TRUNC('month', subq_3.ds) AS revenue_instance__ds__month FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('month', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql index fb051bf687..93350d46a2 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql @@ -9,11 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS revenue_instance__ds__day + DATE_TRUNC('day', ds) AS revenue_instance__ds__day , DATE_TRUNC('month', ds) AS revenue_instance__ds__month FROM ***************************.mf_time_spine subq_10 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('month', ds) ) subq_9 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql index aafb23085c..dd71b55f9b 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql @@ -57,11 +57,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('month', subq_3.ds) AS metric_time__month FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('month', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql index 95a3491e9a..9a236909bd 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql @@ -9,11 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month FROM ***************************.mf_time_spine subq_10 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('month', ds) ) subq_9 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql index aa45e34cfc..845ca470ba 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql @@ -121,8 +121,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql index 4bb70a61f7..f95cf4cf25 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql @@ -8,16 +8,23 @@ FROM ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_11.ds AS metric_time__day + subq_10.metric_time__day AS metric_time__day , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_10 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_11.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_10.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > subq_11.ds - MAKE_INTERVAL(days => 2) + DATE_TRUNC('day', bookings_source_src_28000.ds) > subq_10.metric_time__day - MAKE_INTERVAL(days => 2) ) ) subq_13 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_default_grain__plan0.sql index a83909ad88..550db4382e 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_default_grain__plan0.sql @@ -71,11 +71,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql index 2b6f12b36c..88c6b1d789 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql @@ -23,11 +23,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) ) subq_11 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql index a77410e810..774fc22c99 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql @@ -59,9 +59,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_4.ds AS metric_time__day + DATE_TRUNC('day', subq_4.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_4 WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + DATE_TRUNC('day', subq_4.ds) ) subq_3 INNER JOIN ( -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 6df10259be..3af3e5a797 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -9,9 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_cumulative_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_cumulative_metric_with_non_default_grains__plan0.sql index d370d57659..9f20d48224 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_cumulative_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_cumulative_metric_with_non_default_grains__plan0.sql @@ -72,11 +72,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql index c1d8a4cf36..269bf9bf84 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql @@ -24,11 +24,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week FROM ***************************.mf_time_spine subq_13 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) ) subq_12 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_grain_to_date_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_grain_to_date_metric_with_non_default_grain__plan0.sql index aab94914af..21bf873dcf 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_grain_to_date_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_grain_to_date_metric_with_non_default_grain__plan0.sql @@ -71,11 +71,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('month', subq_3.ds) AS metric_time__month FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('month', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql index 0a70199c86..f85735034b 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql @@ -23,11 +23,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('month', ds) ) subq_11 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_grain_to_date_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_grain_to_date_metric_with_non_default_grains__plan0.sql index 92e8a38290..650e22974b 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_grain_to_date_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_grain_to_date_metric_with_non_default_grains__plan0.sql @@ -80,12 +80,12 @@ FROM ( SELECT DATE_TRUNC('quarter', subq_3.ds) AS revenue_instance__ds__quarter , DATE_TRUNC('year', subq_3.ds) AS revenue_instance__ds__year - , subq_3.ds AS metric_time__day + , DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 GROUP BY DATE_TRUNC('quarter', subq_3.ds) , DATE_TRUNC('year', subq_3.ds) - , subq_3.ds + , DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql index 8f10523e66..b087e7f9fb 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql @@ -30,12 +30,12 @@ FROM ( SELECT DATE_TRUNC('quarter', ds) AS revenue_instance__ds__quarter , DATE_TRUNC('year', ds) AS revenue_instance__ds__year - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_12 GROUP BY DATE_TRUNC('quarter', ds) , DATE_TRUNC('year', ds) - , ds + , DATE_TRUNC('day', ds) ) subq_11 INNER JOIN ***************************.fct_revenue revenue_src_28000 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_window_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_window_metric_with_non_default_grain__plan0.sql index 1a209eb763..97ce7ccb42 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_window_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_window_metric_with_non_default_grain__plan0.sql @@ -67,11 +67,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('year', subq_3.ds) AS metric_time__year FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('year', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_window_metric_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_window_metric_with_non_default_grain__plan0_optimized.sql index 960caea152..b9d42dc88c 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_window_metric_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_window_metric_with_non_default_grain__plan0_optimized.sql @@ -19,11 +19,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('year', ds) AS metric_time__year FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('year', ds) ) subq_11 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_window_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_window_metric_with_non_default_grains__plan0.sql index 6013cb41c7..524077d2a2 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_window_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_window_metric_with_non_default_grains__plan0.sql @@ -32,8 +32,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures @@ -154,12 +156,12 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', subq_3.ds) AS booking__ds__month - , subq_3.ds AS metric_time__day + , DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week FROM ***************************.mf_time_spine subq_3 GROUP BY DATE_TRUNC('month', subq_3.ds) - , subq_3.ds + , DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_window_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_window_metric_with_non_default_grains__plan0_optimized.sql index c16233e6e5..f0d9ccd0e5 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_window_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Postgres/test_window_metric_with_non_default_grains__plan0_optimized.sql @@ -19,11 +19,18 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_20.ds AS metric_time__day - , DATE_TRUNC('week', subq_20.ds) AS metric_time__week + subq_19.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_19.metric_time__day) AS metric_time__week , subq_18.booking__ds__month AS booking__ds__month , subq_18.bookers AS bookers - FROM ***************************.mf_time_spine subq_20 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_19 LEFT OUTER JOIN ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__week', 'booking__ds__month', 'metric_time__day'] @@ -37,12 +44,12 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS booking__ds__month - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week FROM ***************************.mf_time_spine subq_15 GROUP BY DATE_TRUNC('month', ds) - , ds + , DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) ) subq_14 INNER JOIN @@ -59,7 +66,7 @@ FROM ( , subq_14.metric_time__week ) subq_18 ON - subq_20.ds = subq_18.metric_time__day + subq_19.metric_time__day = subq_18.metric_time__day ) subq_21 ) subq_23 GROUP BY diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_all_time_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_all_time_metric_with_non_default_grains__plan0.sql index 29429e102b..2bbe8edce6 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_all_time_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_all_time_metric_with_non_default_grains__plan0.sql @@ -78,12 +78,12 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week , DATE_TRUNC('quarter', subq_3.ds) AS metric_time__quarter FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) , DATE_TRUNC('quarter', subq_3.ds) ) subq_2 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_all_time_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_all_time_metric_with_non_default_grains__plan0_optimized.sql index ea37c15884..818f885944 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_all_time_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_all_time_metric_with_non_default_grains__plan0_optimized.sql @@ -28,12 +28,12 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week , DATE_TRUNC('quarter', ds) AS metric_time__quarter FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) , DATE_TRUNC('quarter', ds) ) subq_11 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index cdbc74960f..97e2d22db0 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -59,9 +59,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_4.ds AS metric_time__day + DATE_TRUNC('day', subq_4.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_4 WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + DATE_TRUNC('day', subq_4.ds) ) subq_3 INNER JOIN ( -- Constrain Time Range to [2000-01-01T00:00:00, 2020-01-01T00:00:00] diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index 0c658869b2..8a451ec0e0 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -9,9 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql index b6b4ae0325..0b53f0c095 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql @@ -58,11 +58,11 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', subq_3.ds) AS revenue_instance__ds__month - , subq_3.ds AS metric_time__day + , DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 GROUP BY DATE_TRUNC('month', subq_3.ds) - , subq_3.ds + , DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql index af273a6d27..f5d971cc7d 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql @@ -10,11 +10,11 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS revenue_instance__ds__month - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 GROUP BY DATE_TRUNC('month', ds) - , ds + , DATE_TRUNC('day', ds) ) subq_9 INNER JOIN ***************************.fct_revenue revenue_src_28000 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_dimension__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_dimension__plan0.sql index 4be662b66d..8efdc86e33 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_dimension__plan0.sql @@ -54,8 +54,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS revenue_instance__ds__day + DATE_TRUNC('day', subq_3.ds) AS revenue_instance__ds__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql index 6fc2ff41b0..e4b2eaa54a 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql @@ -3,16 +3,23 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ds AS revenue_instance__ds__day + subq_9.revenue_instance__ds__day AS revenue_instance__ds__day , SUM(revenue_src_28000.revenue) AS trailing_2_months_revenue -FROM ***************************.mf_time_spine subq_10 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS revenue_instance__ds__day + FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', ds) +) subq_9 INNER JOIN ***************************.fct_revenue revenue_src_28000 ON ( - DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_10.ds + DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_9.revenue_instance__ds__day ) AND ( - DATE_TRUNC('day', revenue_src_28000.created_at) > DATEADD(month, -2, subq_10.ds) + DATE_TRUNC('day', revenue_src_28000.created_at) > DATEADD(month, -2, subq_9.revenue_instance__ds__day) ) GROUP BY - subq_10.ds + subq_9.revenue_instance__ds__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql index 7bd3132dc3..439c9c243a 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql @@ -57,11 +57,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS revenue_instance__ds__day + DATE_TRUNC('day', subq_3.ds) AS revenue_instance__ds__day , DATE_TRUNC('month', subq_3.ds) AS revenue_instance__ds__month FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('month', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql index 6caf616294..118587c14d 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql @@ -9,11 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS revenue_instance__ds__day + DATE_TRUNC('day', ds) AS revenue_instance__ds__day , DATE_TRUNC('month', ds) AS revenue_instance__ds__month FROM ***************************.mf_time_spine subq_10 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('month', ds) ) subq_9 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql index 1d665cb206..9601c32bef 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql @@ -57,11 +57,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('month', subq_3.ds) AS metric_time__month FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('month', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql index 793cd64067..e6c9764b86 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql @@ -9,11 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month FROM ***************************.mf_time_spine subq_10 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('month', ds) ) subq_9 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql index 9d307a8702..839b338b82 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql @@ -121,8 +121,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql index 2d6dabcdb2..d77ed07949 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql @@ -8,16 +8,23 @@ FROM ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_11.ds AS metric_time__day + subq_10.metric_time__day AS metric_time__day , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_10 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_11.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_10.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_11.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_10.metric_time__day) ) ) subq_13 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_default_grain__plan0.sql index 803fc0e985..bf391df06c 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_default_grain__plan0.sql @@ -71,11 +71,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql index 2b6f12b36c..88c6b1d789 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql @@ -23,11 +23,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) ) subq_11 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql index 83bca27502..eb0a8130fc 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql @@ -59,9 +59,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_4.ds AS metric_time__day + DATE_TRUNC('day', subq_4.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_4 WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + DATE_TRUNC('day', subq_4.ds) ) subq_3 INNER JOIN ( -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index cd4811e1ab..7686e4afa2 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -9,9 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_cumulative_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_cumulative_metric_with_non_default_grains__plan0.sql index 909304264a..e58f4e2a62 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_cumulative_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_cumulative_metric_with_non_default_grains__plan0.sql @@ -72,11 +72,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql index 94d66c8da0..94b62d19a4 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql @@ -24,11 +24,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week FROM ***************************.mf_time_spine subq_13 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) ) subq_12 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_grain_to_date_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_grain_to_date_metric_with_non_default_grain__plan0.sql index 1d1319c7ef..70d51ce978 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_grain_to_date_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_grain_to_date_metric_with_non_default_grain__plan0.sql @@ -71,11 +71,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('month', subq_3.ds) AS metric_time__month FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('month', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql index 0a70199c86..f85735034b 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql @@ -23,11 +23,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('month', ds) ) subq_11 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_grain_to_date_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_grain_to_date_metric_with_non_default_grains__plan0.sql index ae51abd0a2..21fb2522e0 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_grain_to_date_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_grain_to_date_metric_with_non_default_grains__plan0.sql @@ -80,12 +80,12 @@ FROM ( SELECT DATE_TRUNC('quarter', subq_3.ds) AS revenue_instance__ds__quarter , DATE_TRUNC('year', subq_3.ds) AS revenue_instance__ds__year - , subq_3.ds AS metric_time__day + , DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 GROUP BY DATE_TRUNC('quarter', subq_3.ds) , DATE_TRUNC('year', subq_3.ds) - , subq_3.ds + , DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql index 8f10523e66..b087e7f9fb 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql @@ -30,12 +30,12 @@ FROM ( SELECT DATE_TRUNC('quarter', ds) AS revenue_instance__ds__quarter , DATE_TRUNC('year', ds) AS revenue_instance__ds__year - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_12 GROUP BY DATE_TRUNC('quarter', ds) , DATE_TRUNC('year', ds) - , ds + , DATE_TRUNC('day', ds) ) subq_11 INNER JOIN ***************************.fct_revenue revenue_src_28000 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_window_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_window_metric_with_non_default_grain__plan0.sql index c49c049b91..32ae3eaa6b 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_window_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_window_metric_with_non_default_grain__plan0.sql @@ -67,11 +67,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('year', subq_3.ds) AS metric_time__year FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('year', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_window_metric_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_window_metric_with_non_default_grain__plan0_optimized.sql index f2214f335f..0a69472e63 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_window_metric_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_window_metric_with_non_default_grain__plan0_optimized.sql @@ -19,11 +19,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('year', ds) AS metric_time__year FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('year', ds) ) subq_11 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_window_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_window_metric_with_non_default_grains__plan0.sql index 81608c0b83..0cdfd84a4f 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_window_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_window_metric_with_non_default_grains__plan0.sql @@ -32,8 +32,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures @@ -154,12 +156,12 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', subq_3.ds) AS booking__ds__month - , subq_3.ds AS metric_time__day + , DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week FROM ***************************.mf_time_spine subq_3 GROUP BY DATE_TRUNC('month', subq_3.ds) - , subq_3.ds + , DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_window_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_window_metric_with_non_default_grains__plan0_optimized.sql index 40268062b2..eb798e6691 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_window_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Redshift/test_window_metric_with_non_default_grains__plan0_optimized.sql @@ -19,11 +19,18 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_20.ds AS metric_time__day - , DATE_TRUNC('week', subq_20.ds) AS metric_time__week + subq_19.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_19.metric_time__day) AS metric_time__week , subq_18.booking__ds__month AS booking__ds__month , subq_18.bookers AS bookers - FROM ***************************.mf_time_spine subq_20 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_19 LEFT OUTER JOIN ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__week', 'booking__ds__month', 'metric_time__day'] @@ -37,12 +44,12 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS booking__ds__month - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week FROM ***************************.mf_time_spine subq_15 GROUP BY DATE_TRUNC('month', ds) - , ds + , DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) ) subq_14 INNER JOIN @@ -59,7 +66,7 @@ FROM ( , subq_14.metric_time__week ) subq_18 ON - subq_20.ds = subq_18.metric_time__day + subq_19.metric_time__day = subq_18.metric_time__day ) subq_21 ) subq_23 GROUP BY diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_all_time_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_all_time_metric_with_non_default_grains__plan0.sql index 1c9a57d92b..fc9be78222 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_all_time_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_all_time_metric_with_non_default_grains__plan0.sql @@ -78,12 +78,12 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week , DATE_TRUNC('quarter', subq_3.ds) AS metric_time__quarter FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) , DATE_TRUNC('quarter', subq_3.ds) ) subq_2 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_all_time_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_all_time_metric_with_non_default_grains__plan0_optimized.sql index ea37c15884..818f885944 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_all_time_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_all_time_metric_with_non_default_grains__plan0_optimized.sql @@ -28,12 +28,12 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week , DATE_TRUNC('quarter', ds) AS metric_time__quarter FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) , DATE_TRUNC('quarter', ds) ) subq_11 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index bc939ab7fb..dda41254f1 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -59,9 +59,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_4.ds AS metric_time__day + DATE_TRUNC('day', subq_4.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_4 WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + DATE_TRUNC('day', subq_4.ds) ) subq_3 INNER JOIN ( -- Constrain Time Range to [2000-01-01T00:00:00, 2020-01-01T00:00:00] diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index 0c658869b2..8a451ec0e0 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -9,9 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql index 291d204d49..fe95612206 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql @@ -58,11 +58,11 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', subq_3.ds) AS revenue_instance__ds__month - , subq_3.ds AS metric_time__day + , DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 GROUP BY DATE_TRUNC('month', subq_3.ds) - , subq_3.ds + , DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql index af273a6d27..f5d971cc7d 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql @@ -10,11 +10,11 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS revenue_instance__ds__month - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 GROUP BY DATE_TRUNC('month', ds) - , ds + , DATE_TRUNC('day', ds) ) subq_9 INNER JOIN ***************************.fct_revenue revenue_src_28000 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_dimension__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_dimension__plan0.sql index 9eb08b31fe..4c67d30773 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_dimension__plan0.sql @@ -54,8 +54,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS revenue_instance__ds__day + DATE_TRUNC('day', subq_3.ds) AS revenue_instance__ds__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql index 6fc2ff41b0..e4b2eaa54a 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql @@ -3,16 +3,23 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ds AS revenue_instance__ds__day + subq_9.revenue_instance__ds__day AS revenue_instance__ds__day , SUM(revenue_src_28000.revenue) AS trailing_2_months_revenue -FROM ***************************.mf_time_spine subq_10 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS revenue_instance__ds__day + FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', ds) +) subq_9 INNER JOIN ***************************.fct_revenue revenue_src_28000 ON ( - DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_10.ds + DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_9.revenue_instance__ds__day ) AND ( - DATE_TRUNC('day', revenue_src_28000.created_at) > DATEADD(month, -2, subq_10.ds) + DATE_TRUNC('day', revenue_src_28000.created_at) > DATEADD(month, -2, subq_9.revenue_instance__ds__day) ) GROUP BY - subq_10.ds + subq_9.revenue_instance__ds__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql index bbb80a8f2c..226b2e8f57 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql @@ -57,11 +57,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS revenue_instance__ds__day + DATE_TRUNC('day', subq_3.ds) AS revenue_instance__ds__day , DATE_TRUNC('month', subq_3.ds) AS revenue_instance__ds__month FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('month', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql index 6caf616294..118587c14d 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql @@ -9,11 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS revenue_instance__ds__day + DATE_TRUNC('day', ds) AS revenue_instance__ds__day , DATE_TRUNC('month', ds) AS revenue_instance__ds__month FROM ***************************.mf_time_spine subq_10 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('month', ds) ) subq_9 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql index 9ea017acab..fe5b7e1345 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql @@ -57,11 +57,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('month', subq_3.ds) AS metric_time__month FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('month', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql index 793cd64067..e6c9764b86 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql @@ -9,11 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month FROM ***************************.mf_time_spine subq_10 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('month', ds) ) subq_9 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql index c85fb774a3..e0e3bdb660 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql @@ -121,8 +121,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql index 2d6dabcdb2..d77ed07949 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql @@ -8,16 +8,23 @@ FROM ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_11.ds AS metric_time__day + subq_10.metric_time__day AS metric_time__day , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_10 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_11.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_10.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_11.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_10.metric_time__day) ) ) subq_13 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_default_grain__plan0.sql index 1e140d9bee..01ddb62444 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_default_grain__plan0.sql @@ -71,11 +71,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql index 2b6f12b36c..88c6b1d789 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql @@ -23,11 +23,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) ) subq_11 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql index 1a6cd4c601..87861ad482 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql @@ -59,9 +59,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_4.ds AS metric_time__day + DATE_TRUNC('day', subq_4.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_4 WHERE subq_4.ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + DATE_TRUNC('day', subq_4.ds) ) subq_3 INNER JOIN ( -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index cd4811e1ab..7686e4afa2 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -9,9 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_cumulative_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_cumulative_metric_with_non_default_grains__plan0.sql index fe91f8515e..74239ceb1f 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_cumulative_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_cumulative_metric_with_non_default_grains__plan0.sql @@ -72,11 +72,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql index 94d66c8da0..94b62d19a4 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql @@ -24,11 +24,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week FROM ***************************.mf_time_spine subq_13 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) ) subq_12 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_grain_to_date_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_grain_to_date_metric_with_non_default_grain__plan0.sql index 421acf6ca5..21d70511e0 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_grain_to_date_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_grain_to_date_metric_with_non_default_grain__plan0.sql @@ -71,11 +71,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('month', subq_3.ds) AS metric_time__month FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('month', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql index 0a70199c86..f85735034b 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql @@ -23,11 +23,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('month', ds) ) subq_11 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_grain_to_date_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_grain_to_date_metric_with_non_default_grains__plan0.sql index 06484eb416..e747557a7e 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_grain_to_date_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_grain_to_date_metric_with_non_default_grains__plan0.sql @@ -80,12 +80,12 @@ FROM ( SELECT DATE_TRUNC('quarter', subq_3.ds) AS revenue_instance__ds__quarter , DATE_TRUNC('year', subq_3.ds) AS revenue_instance__ds__year - , subq_3.ds AS metric_time__day + , DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 GROUP BY DATE_TRUNC('quarter', subq_3.ds) , DATE_TRUNC('year', subq_3.ds) - , subq_3.ds + , DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql index 8f10523e66..b087e7f9fb 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql @@ -30,12 +30,12 @@ FROM ( SELECT DATE_TRUNC('quarter', ds) AS revenue_instance__ds__quarter , DATE_TRUNC('year', ds) AS revenue_instance__ds__year - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_12 GROUP BY DATE_TRUNC('quarter', ds) , DATE_TRUNC('year', ds) - , ds + , DATE_TRUNC('day', ds) ) subq_11 INNER JOIN ***************************.fct_revenue revenue_src_28000 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_window_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_window_metric_with_non_default_grain__plan0.sql index 5ff4e09f97..71d4e8605c 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_window_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_window_metric_with_non_default_grain__plan0.sql @@ -67,11 +67,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('year', subq_3.ds) AS metric_time__year FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('year', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_window_metric_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_window_metric_with_non_default_grain__plan0_optimized.sql index f2214f335f..0a69472e63 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_window_metric_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_window_metric_with_non_default_grain__plan0_optimized.sql @@ -19,11 +19,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('year', ds) AS metric_time__year FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('year', ds) ) subq_11 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_window_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_window_metric_with_non_default_grains__plan0.sql index 54f9b7a5f9..20a492c208 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_window_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_window_metric_with_non_default_grains__plan0.sql @@ -32,8 +32,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures @@ -154,12 +156,12 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', subq_3.ds) AS booking__ds__month - , subq_3.ds AS metric_time__day + , DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week FROM ***************************.mf_time_spine subq_3 GROUP BY DATE_TRUNC('month', subq_3.ds) - , subq_3.ds + , DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_window_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_window_metric_with_non_default_grains__plan0_optimized.sql index 40268062b2..eb798e6691 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_window_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Snowflake/test_window_metric_with_non_default_grains__plan0_optimized.sql @@ -19,11 +19,18 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_20.ds AS metric_time__day - , DATE_TRUNC('week', subq_20.ds) AS metric_time__week + subq_19.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_19.metric_time__day) AS metric_time__week , subq_18.booking__ds__month AS booking__ds__month , subq_18.bookers AS bookers - FROM ***************************.mf_time_spine subq_20 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_19 LEFT OUTER JOIN ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__week', 'booking__ds__month', 'metric_time__day'] @@ -37,12 +44,12 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS booking__ds__month - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week FROM ***************************.mf_time_spine subq_15 GROUP BY DATE_TRUNC('month', ds) - , ds + , DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) ) subq_14 INNER JOIN @@ -59,7 +66,7 @@ FROM ( , subq_14.metric_time__week ) subq_18 ON - subq_20.ds = subq_18.metric_time__day + subq_19.metric_time__day = subq_18.metric_time__day ) subq_21 ) subq_23 GROUP BY diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_all_time_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_all_time_metric_with_non_default_grains__plan0.sql index 8a5ddb3468..2499de0a74 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_all_time_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_all_time_metric_with_non_default_grains__plan0.sql @@ -78,12 +78,12 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week , DATE_TRUNC('quarter', subq_3.ds) AS metric_time__quarter FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) , DATE_TRUNC('quarter', subq_3.ds) ) subq_2 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_all_time_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_all_time_metric_with_non_default_grains__plan0_optimized.sql index ea37c15884..818f885944 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_all_time_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_all_time_metric_with_non_default_grains__plan0_optimized.sql @@ -28,12 +28,12 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week , DATE_TRUNC('quarter', ds) AS metric_time__quarter FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) , DATE_TRUNC('quarter', ds) ) subq_11 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index cd2967d1e1..03b1960659 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -59,9 +59,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_4.ds AS metric_time__day + DATE_TRUNC('day', subq_4.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_4 WHERE subq_4.ds BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' + GROUP BY + DATE_TRUNC('day', subq_4.ds) ) subq_3 INNER JOIN ( -- Constrain Time Range to [2000-01-01T00:00:00, 2020-01-01T00:00:00] diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index 5f0ebfafd1..9d3b86666b 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -9,9 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql index 273e14d03f..c7a599c875 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_and_metric_time__plan0.sql @@ -58,11 +58,11 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', subq_3.ds) AS revenue_instance__ds__month - , subq_3.ds AS metric_time__day + , DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 GROUP BY DATE_TRUNC('month', subq_3.ds) - , subq_3.ds + , DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql index 251cdb4cb8..3bd0dd3d99 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_and_metric_time__plan0_optimized.sql @@ -10,11 +10,11 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS revenue_instance__ds__month - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 GROUP BY DATE_TRUNC('month', ds) - , ds + , DATE_TRUNC('day', ds) ) subq_9 INNER JOIN ***************************.fct_revenue revenue_src_28000 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_dimension__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_dimension__plan0.sql index cfce01690b..d32e0f72f0 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_dimension__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_dimension__plan0.sql @@ -54,8 +54,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS revenue_instance__ds__day + DATE_TRUNC('day', subq_3.ds) AS revenue_instance__ds__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql index b4beca7e7f..ae84e62d22 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_agg_time_dimension__plan0_optimized.sql @@ -3,16 +3,23 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ds AS revenue_instance__ds__day + subq_9.revenue_instance__ds__day AS revenue_instance__ds__day , SUM(revenue_src_28000.revenue) AS trailing_2_months_revenue -FROM ***************************.mf_time_spine subq_10 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS revenue_instance__ds__day + FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', ds) +) subq_9 INNER JOIN ***************************.fct_revenue revenue_src_28000 ON ( - DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_10.ds + DATE_TRUNC('day', revenue_src_28000.created_at) <= subq_9.revenue_instance__ds__day ) AND ( - DATE_TRUNC('day', revenue_src_28000.created_at) > DATE_ADD('month', -2, subq_10.ds) + DATE_TRUNC('day', revenue_src_28000.created_at) > DATE_ADD('month', -2, subq_9.revenue_instance__ds__day) ) GROUP BY - subq_10.ds + subq_9.revenue_instance__ds__day diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql index 6c3054ee99..5256be15f8 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql @@ -57,11 +57,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS revenue_instance__ds__day + DATE_TRUNC('day', subq_3.ds) AS revenue_instance__ds__day , DATE_TRUNC('month', subq_3.ds) AS revenue_instance__ds__month FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('month', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql index 6072af4f6d..bbdc10b7af 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0_optimized.sql @@ -9,11 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS revenue_instance__ds__day + DATE_TRUNC('day', ds) AS revenue_instance__ds__day , DATE_TRUNC('month', ds) AS revenue_instance__ds__month FROM ***************************.mf_time_spine subq_10 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('month', ds) ) subq_9 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql index 4ab76dcbe5..94a810eaf5 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql @@ -57,11 +57,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('month', subq_3.ds) AS metric_time__month FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('month', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql index a2359e82ea..165364ff01 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0_optimized.sql @@ -9,11 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month FROM ***************************.mf_time_spine subq_10 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('month', ds) ) subq_9 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql index 5590d25022..47984c4a57 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0.sql @@ -121,8 +121,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql index e51229645c..79eb979788 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_adjustable_time_filter__plan0_optimized.sql @@ -8,16 +8,23 @@ FROM ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] SELECT - subq_11.ds AS metric_time__day + subq_10.metric_time__day AS metric_time__day , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_10 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_11.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_10.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATE_ADD('day', -2, subq_11.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATE_ADD('day', -2, subq_10.metric_time__day) ) ) subq_13 WHERE metric_time__day = '2020-01-03' or metric_time__day = '2020-01-07' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_default_grain__plan0.sql index 050b90fe7a..f4221dbfe1 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_default_grain__plan0.sql @@ -71,11 +71,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql index 2b6f12b36c..88c6b1d789 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_non_default_grain__plan0_optimized.sql @@ -23,11 +23,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) ) subq_11 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql index 7ea5b21ac4..865013d6bc 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0.sql @@ -59,9 +59,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_4.ds AS metric_time__day + DATE_TRUNC('day', subq_4.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_4 WHERE subq_4.ds BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' + GROUP BY + DATE_TRUNC('day', subq_4.ds) ) subq_3 INNER JOIN ( -- Constrain Time Range to [2019-11-01T00:00:00, 2020-01-01T00:00:00] diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 14fdc3b055..9eaf9a111b 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -9,9 +9,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN timestamp '2020-01-01' AND timestamp '2020-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'revenue' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_derived_cumulative_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_derived_cumulative_metric_with_non_default_grains__plan0.sql index 7a89445ace..781a6c5b1c 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_derived_cumulative_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_derived_cumulative_metric_with_non_default_grains__plan0.sql @@ -72,11 +72,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql index f052f1929e..bc11b9209c 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_derived_cumulative_metric_with_non_default_grains__plan0_optimized.sql @@ -24,11 +24,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week FROM ***************************.mf_time_spine subq_13 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) ) subq_12 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_grain_to_date_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_grain_to_date_metric_with_non_default_grain__plan0.sql index d94209433b..fa599cbad9 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_grain_to_date_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_grain_to_date_metric_with_non_default_grain__plan0.sql @@ -71,11 +71,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('month', subq_3.ds) AS metric_time__month FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('month', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql index 0a70199c86..f85735034b 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_grain_to_date_metric_with_non_default_grain__plan0_optimized.sql @@ -23,11 +23,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('month', ds) AS metric_time__month FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('month', ds) ) subq_11 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_grain_to_date_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_grain_to_date_metric_with_non_default_grains__plan0.sql index c980cdc75d..3bb007f5f0 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_grain_to_date_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_grain_to_date_metric_with_non_default_grains__plan0.sql @@ -80,12 +80,12 @@ FROM ( SELECT DATE_TRUNC('quarter', subq_3.ds) AS revenue_instance__ds__quarter , DATE_TRUNC('year', subq_3.ds) AS revenue_instance__ds__year - , subq_3.ds AS metric_time__day + , DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 GROUP BY DATE_TRUNC('quarter', subq_3.ds) , DATE_TRUNC('year', subq_3.ds) - , subq_3.ds + , DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql index 8f10523e66..b087e7f9fb 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_grain_to_date_metric_with_non_default_grains__plan0_optimized.sql @@ -30,12 +30,12 @@ FROM ( SELECT DATE_TRUNC('quarter', ds) AS revenue_instance__ds__quarter , DATE_TRUNC('year', ds) AS revenue_instance__ds__year - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_12 GROUP BY DATE_TRUNC('quarter', ds) , DATE_TRUNC('year', ds) - , ds + , DATE_TRUNC('day', ds) ) subq_11 INNER JOIN ***************************.fct_revenue revenue_src_28000 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_window_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_window_metric_with_non_default_grain__plan0.sql index 06f1486ac1..795fb2ded9 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_window_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_window_metric_with_non_default_grain__plan0.sql @@ -67,11 +67,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('year', subq_3.ds) AS metric_time__year FROM ***************************.mf_time_spine subq_3 GROUP BY - subq_3.ds + DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('year', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_window_metric_with_non_default_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_window_metric_with_non_default_grain__plan0_optimized.sql index 5d3f4efe05..79e73b1ff1 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_window_metric_with_non_default_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_window_metric_with_non_default_grain__plan0_optimized.sql @@ -19,11 +19,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('year', ds) AS metric_time__year FROM ***************************.mf_time_spine subq_12 GROUP BY - ds + DATE_TRUNC('day', ds) , DATE_TRUNC('year', ds) ) subq_11 INNER JOIN diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_window_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_window_metric_with_non_default_grains__plan0.sql index 807067cba5..adb92edf79 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_window_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_window_metric_with_non_default_grains__plan0.sql @@ -32,8 +32,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures @@ -154,12 +156,12 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', subq_3.ds) AS booking__ds__month - , subq_3.ds AS metric_time__day + , DATE_TRUNC('day', subq_3.ds) AS metric_time__day , DATE_TRUNC('week', subq_3.ds) AS metric_time__week FROM ***************************.mf_time_spine subq_3 GROUP BY DATE_TRUNC('month', subq_3.ds) - , subq_3.ds + , DATE_TRUNC('day', subq_3.ds) , DATE_TRUNC('week', subq_3.ds) ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_window_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_window_metric_with_non_default_grains__plan0_optimized.sql index 7ed947b747..900605eeaa 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_window_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/Trino/test_window_metric_with_non_default_grains__plan0_optimized.sql @@ -19,11 +19,18 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_20.ds AS metric_time__day - , DATE_TRUNC('week', subq_20.ds) AS metric_time__week + subq_19.metric_time__day AS metric_time__day + , DATE_TRUNC('week', subq_19.metric_time__day) AS metric_time__week , subq_18.booking__ds__month AS booking__ds__month , subq_18.bookers AS bookers - FROM ***************************.mf_time_spine subq_20 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_19 LEFT OUTER JOIN ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__week', 'booking__ds__month', 'metric_time__day'] @@ -37,12 +44,12 @@ FROM ( -- Time Spine SELECT DATE_TRUNC('month', ds) AS booking__ds__month - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week FROM ***************************.mf_time_spine subq_15 GROUP BY DATE_TRUNC('month', ds) - , ds + , DATE_TRUNC('day', ds) , DATE_TRUNC('week', ds) ) subq_14 INNER JOIN @@ -59,7 +66,7 @@ FROM ( , subq_14.metric_time__week ) subq_18 ON - subq_20.ds = subq_18.metric_time__day + subq_19.metric_time__day = subq_18.metric_time__day ) subq_21 ) subq_23 GROUP BY diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index ea342dd3b9..23a37cd788 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATETIME_TRUNC(subq_6.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + metric_time__day ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index c13f6cf11d..ddbefca69f 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATETIME_TRUNC(ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + metric_time__day ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0.sql index 9594d9ef88..dcd8af6a79 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATETIME_TRUNC(subq_6.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + metric_time__day ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index b86e41cd63..d0ce8607c1 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATETIME_TRUNC(ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + metric_time__day ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0.sql index 3d64a5d15d..855f80b76a 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATETIME_TRUNC(subq_6.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + metric_time__day ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index afecd64116..9baae069db 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATETIME_TRUNC(ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + metric_time__day ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index eec56d28b8..b9f80b2c3f 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index 6054b232dc..619fe8dda3 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0.sql index 278352a1b4..7e19f51309 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index 61bc9299ec..c0b3032bad 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0.sql index 84ae7ad473..a3539f0ee3 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index e4f47734b0..5526f612ef 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index d1eb9e6cdf..a233b840e1 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index 6054b232dc..619fe8dda3 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0.sql index cd070b2730..3688811128 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index 21b1f16711..b5403c211a 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0.sql index 2c925cc021..2cde263f64 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index e4f47734b0..5526f612ef 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index 08f2336170..9ea7458628 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index 6054b232dc..619fe8dda3 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0.sql index dc9b6b2769..40974eec73 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index 61bc9299ec..c0b3032bad 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0.sql index b0708bcdc2..ba2dcd0dd7 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index e4f47734b0..5526f612ef 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index 2689896e19..794aa1257a 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index 6054b232dc..619fe8dda3 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0.sql index 6fbac4ea91..6c58391a65 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index 61bc9299ec..c0b3032bad 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0.sql index 43273b80a2..28e1cb6d30 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index e4f47734b0..5526f612ef 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN '2020-01-01' AND '2021-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index e8a3b24016..417c727b1d 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN timestamp '2020-01-01' AND timestamp '2021-01-01' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index dfbf45320a..82fcde8780 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN timestamp '2020-01-01' AND timestamp '2021-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0.sql index 02c8875b37..629f896299 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN timestamp '2020-01-01' AND timestamp '2021-01-01' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index 46290a43a2..5e2b93a6ce 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN timestamp '2020-01-01' AND timestamp '2021-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0.sql index a6b2e3622c..e4fbbcd8e6 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN timestamp '2020-01-01' AND timestamp '2021-01-01' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index 079f6f5209..a58911d67d 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Trino/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -6,9 +6,11 @@ SELECT FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_13 WHERE ds BETWEEN timestamp '2020-01-01' AND timestamp '2021-01-01' + GROUP BY + DATE_TRUNC('day', ds) ) subq_12 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index 2076a0ccf1..d61b6b343d 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -126,9 +126,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATETIME_TRUNC(subq_6.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + metric_time__day ) subq_5 INNER JOIN ( -- Join Self Over Time Range @@ -234,8 +236,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + metric_time__day ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql index b50ea33e0f..fc50c42b26 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -14,23 +14,32 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATETIME_TRUNC(ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_18 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + metric_time__day ) subq_17 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + metric_time__day + ) subq_14 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATETIME_TRUNC(bookings_source_src_28000.ds, day) <= subq_15.ds + DATETIME_TRUNC(bookings_source_src_28000.ds, day) <= subq_14.metric_time__day ) AND ( - DATETIME_TRUNC(bookings_source_src_28000.ds, day) > DATE_SUB(CAST(subq_15.ds AS DATETIME), INTERVAL 2 day) + DATETIME_TRUNC(bookings_source_src_28000.ds, day) > DATE_SUB(CAST(subq_14.metric_time__day AS DATETIME), INTERVAL 2 day) ) ) subq_16 ON diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql index 75aba4803b..402098ec28 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATETIME_TRUNC(subq_8.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + metric_time__day ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index 01998e04e7..9b14220199 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + metric_time__day + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,7 +51,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATETIME_TRUNC(subq_22.ds, month) = subq_20.metric_time__day + DATETIME_TRUNC(subq_21.metric_time__day, month) = subq_20.metric_time__day GROUP BY metric_time__day ) subq_26 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index 5c258a4743..9b4aebc2c0 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATETIME_TRUNC(subq_8.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + metric_time__day ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index 0adabcc5db..6b3a3081d1 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATETIME_TRUNC(subq_22.ds, isoweek) AS metric_time__week + DATETIME_TRUNC(subq_21.metric_time__day, isoweek) AS metric_time__week , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + metric_time__day + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,8 +51,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATETIME_TRUNC(subq_22.ds, month) = subq_20.metric_time__day - WHERE DATETIME_TRUNC(subq_22.ds, isoweek) = subq_22.ds + DATETIME_TRUNC(subq_21.metric_time__day, month) = subq_20.metric_time__day + WHERE DATETIME_TRUNC(subq_21.metric_time__day, isoweek) = subq_21.metric_time__day GROUP BY metric_time__week ) subq_26 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql index 573fbfce44..85fe2ca4ee 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATETIME_TRUNC(subq_8.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + metric_time__day ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0_optimized.sql index afd37a8346..a9d5f6da3a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + metric_time__day + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,7 +51,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_SUB(CAST(subq_22.ds AS DATETIME), INTERVAL 14 day) = subq_20.metric_time__day + DATE_SUB(CAST(subq_21.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_20.metric_time__day GROUP BY metric_time__day ) subq_26 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 7c1434ec44..b8b8dcb7db 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATETIME_TRUNC(subq_8.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + metric_time__day ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index a53541bac3..4a9dcfee6b 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATETIME_TRUNC(subq_22.ds, quarter) AS metric_time__quarter + DATETIME_TRUNC(subq_21.metric_time__day, quarter) AS metric_time__quarter , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + metric_time__day + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,7 +51,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_SUB(CAST(subq_22.ds AS DATETIME), INTERVAL 14 day) = subq_20.metric_time__day + DATE_SUB(CAST(subq_21.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_20.metric_time__day GROUP BY metric_time__quarter ) subq_26 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 233c22cc2f..eaa677f639 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -127,8 +127,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + metric_time__day ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' @@ -452,8 +454,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day + DATETIME_TRUNC(subq_11.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_11 + GROUP BY + metric_time__day ) subq_10 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 40ca32a94a..c3e9336bf0 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -14,9 +14,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_20.ds AS metric_time__day + subq_19.metric_time__day AS metric_time__day , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + GROUP BY + metric_time__day + ) subq_19 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -26,7 +33,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_18 ON - DATETIME_TRUNC(subq_20.ds, month) = subq_18.metric_time__day + DATETIME_TRUNC(subq_19.metric_time__day, month) = subq_18.metric_time__day GROUP BY metric_time__day ) subq_24 @@ -36,9 +43,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day + subq_27.metric_time__day AS metric_time__day , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_28 + GROUP BY + metric_time__day + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -48,7 +62,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_26 ON - DATE_SUB(CAST(subq_28.ds AS DATETIME), INTERVAL 1 month) = subq_26.metric_time__day + DATE_SUB(CAST(subq_27.metric_time__day AS DATETIME), INTERVAL 1 month) = subq_26.metric_time__day GROUP BY metric_time__day ) subq_32 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index 71afc56e73..a3167a2cd0 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -127,8 +127,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + metric_time__day ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' @@ -453,8 +455,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day + DATETIME_TRUNC(subq_11.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_11 + GROUP BY + metric_time__day ) subq_10 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 84e29631ce..f730b1a29d 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -14,9 +14,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATETIME_TRUNC(subq_20.ds, year) AS metric_time__year + DATETIME_TRUNC(subq_19.metric_time__day, year) AS metric_time__year , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + GROUP BY + metric_time__day + ) subq_19 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -26,8 +33,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_18 ON - DATETIME_TRUNC(subq_20.ds, month) = subq_18.metric_time__day - WHERE DATETIME_TRUNC(subq_20.ds, year) = subq_20.ds + DATETIME_TRUNC(subq_19.metric_time__day, month) = subq_18.metric_time__day + WHERE DATETIME_TRUNC(subq_19.metric_time__day, year) = subq_19.metric_time__day GROUP BY metric_time__year ) subq_24 @@ -37,9 +44,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATETIME_TRUNC(subq_28.ds, year) AS metric_time__year + DATETIME_TRUNC(subq_27.metric_time__day, year) AS metric_time__year , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_28 + GROUP BY + metric_time__day + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -49,7 +63,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_26 ON - DATE_SUB(CAST(subq_28.ds AS DATETIME), INTERVAL 1 month) = subq_26.metric_time__day + DATE_SUB(CAST(subq_27.metric_time__day AS DATETIME), INTERVAL 1 month) = subq_26.metric_time__day GROUP BY metric_time__year ) subq_32 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 8a5180f7c6..53a65da92a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -354,8 +354,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day + DATETIME_TRUNC(subq_9.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_9 + GROUP BY + metric_time__day ) subq_8 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql index de4960ffcf..24c1746bfc 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql @@ -39,9 +39,16 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_25.ds AS metric_time__day + subq_24.metric_time__day AS metric_time__day , subq_23.bookings AS bookings - FROM ***************************.mf_time_spine subq_25 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_25 + GROUP BY + metric_time__day + ) subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -51,7 +58,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_23 ON - DATE_SUB(CAST(subq_25.ds AS DATETIME), INTERVAL 14 day) = subq_23.metric_time__day + DATE_SUB(CAST(subq_24.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_23.metric_time__day ) subq_27 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0.sql index c384bf36f4..2279e58abb 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0.sql @@ -121,8 +121,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATETIME_TRUNC(subq_6.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_6 + GROUP BY + metric_time__day ) subq_5 INNER JOIN ( -- Join Self Over Time Range @@ -228,8 +230,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + metric_time__day ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0_optimized.sql index 4b9b513bb2..ca10dfd7ee 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -8,26 +8,40 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day + subq_16.metric_time__day AS metric_time__day , COUNT(DISTINCT subq_15.bookers) AS every_2_days_bookers_2_days_ago - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + metric_time__day + ) subq_16 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_14.ds AS metric_time__day + subq_13.metric_time__day AS metric_time__day , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_14 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + GROUP BY + metric_time__day + ) subq_13 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATETIME_TRUNC(bookings_source_src_28000.ds, day) <= subq_14.ds + DATETIME_TRUNC(bookings_source_src_28000.ds, day) <= subq_13.metric_time__day ) AND ( - DATETIME_TRUNC(bookings_source_src_28000.ds, day) > DATE_SUB(CAST(subq_14.ds AS DATETIME), INTERVAL 2 day) + DATETIME_TRUNC(bookings_source_src_28000.ds, day) > DATE_SUB(CAST(subq_13.metric_time__day AS DATETIME), INTERVAL 2 day) ) ) subq_15 ON - DATE_SUB(CAST(subq_17.ds AS DATETIME), INTERVAL 2 day) = subq_15.metric_time__day + DATE_SUB(CAST(subq_16.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_15.metric_time__day GROUP BY metric_time__day ) subq_21 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0.sql index 92af66db4c..44c41649ca 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -127,8 +127,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS booking__ds__day + DATETIME_TRUNC(subq_3.ds, day) AS booking__ds__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + booking__ds__day ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql index 6e331d4e16..7a22a7e4f0 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql @@ -14,13 +14,20 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS booking__ds__day + subq_16.booking__ds__day AS booking__ds__day , SUM(bookings_source_src_28000.booking_value) AS booking_value - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + booking__ds__day + ) subq_16 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATE_SUB(CAST(subq_17.ds AS DATETIME), INTERVAL 1 week) = DATETIME_TRUNC(bookings_source_src_28000.ds, day) + DATE_SUB(CAST(subq_16.booking__ds__day AS DATETIME), INTERVAL 1 week) = DATETIME_TRUNC(bookings_source_src_28000.ds, day) GROUP BY booking__ds__day ) subq_21 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0.sql index 5c4ee22ca1..792ef72c61 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -121,8 +121,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + metric_time__day ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index de4b0b1da5..b269fc715b 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -8,9 +8,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day + subq_10.metric_time__day AS metric_time__day , SUM(subq_9.bookings) AS bookings_5_days_ago - FROM ***************************.mf_time_spine subq_11 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_11 + GROUP BY + metric_time__day + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -20,7 +27,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_9 ON - DATE_SUB(CAST(subq_11.ds AS DATETIME), INTERVAL 5 day) = subq_9.metric_time__day + DATE_SUB(CAST(subq_10.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_9.metric_time__day GROUP BY metric_time__day ) subq_15 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index 38abfd9503..b0b21ea786 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -22,8 +22,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATETIME_TRUNC(subq_10.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_10 + GROUP BY + metric_time__day ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -153,8 +155,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + metric_time__day ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index 0fab73319b..b83d217f1d 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -11,10 +11,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_24.ds AS metric_time__day + subq_23.metric_time__day AS metric_time__day , subq_22.booking__is_instant AS booking__is_instant , subq_22.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_24 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_24 + GROUP BY + metric_time__day + ) subq_23 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -27,10 +34,17 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day + subq_16.metric_time__day AS metric_time__day , subq_15.booking__is_instant AS booking__is_instant , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + metric_time__day + ) subq_16 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -41,14 +55,14 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_15 ON - DATE_SUB(CAST(subq_17.ds AS DATETIME), INTERVAL 5 day) = subq_15.metric_time__day + DATE_SUB(CAST(subq_16.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_15.metric_time__day GROUP BY metric_time__day , booking__is_instant ) subq_21 ) subq_22 ON - DATE_SUB(CAST(subq_24.ds AS DATETIME), INTERVAL 2 day) = subq_22.metric_time__day + DATE_SUB(CAST(subq_23.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_22.metric_time__day ) subq_25 WHERE booking__is_instant ) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql index f96b3ee476..42f227f9ba 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql @@ -16,8 +16,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day + DATETIME_TRUNC(subq_7.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_7 + GROUP BY + metric_time__day ) subq_6 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql index d7d67e9177..b88d2f50b6 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql @@ -11,9 +11,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day + subq_22.metric_time__day AS metric_time__day , subq_21.booking_fees_start_of_month AS booking_fees_start_of_month - FROM ***************************.mf_time_spine subq_23 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_23 + GROUP BY + metric_time__day + ) subq_22 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -34,7 +41,7 @@ FROM ( ) subq_20 ) subq_21 ON - DATETIME_TRUNC(subq_23.ds, month) = subq_21.metric_time__day + DATETIME_TRUNC(subq_22.metric_time__day, month) = subq_21.metric_time__day ) subq_24 FULL OUTER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets__plan0.sql index ce02d3f754..f32a5bdd52 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATETIME_TRUNC(subq_10.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_10 + GROUP BY + metric_time__day ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -137,8 +139,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + metric_time__day ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets__plan0_optimized.sql index 95482a7759..ccbd65b97a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets__plan0_optimized.sql @@ -5,9 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , subq_20.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + metric_time__day + ) subq_21 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -19,9 +26,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + metric_time__day + ) subq_14 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -31,11 +45,11 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_13 ON - DATE_SUB(CAST(subq_15.ds AS DATETIME), INTERVAL 5 day) = subq_13.metric_time__day + DATE_SUB(CAST(subq_14.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_13.metric_time__day GROUP BY metric_time__day ) subq_19 ) subq_20 ON - DATE_SUB(CAST(subq_22.ds AS DATETIME), INTERVAL 2 day) = subq_20.metric_time__day + DATE_SUB(CAST(subq_21.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_20.metric_time__day ) subq_23 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0.sql index 9c0be8d3b7..e66d04808b 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0.sql @@ -10,9 +10,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATETIME_TRUNC(subq_10.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_10 WHERE subq_10.ds BETWEEN '2020-01-12' AND '2020-01-13' + GROUP BY + metric_time__day ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -138,8 +140,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + metric_time__day ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0_optimized.sql index 883e2c5d74..1ceb723170 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -10,9 +10,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATETIME_TRUNC(ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_22 WHERE ds BETWEEN '2020-01-12' AND '2020-01-13' + GROUP BY + metric_time__day ) subq_21 INNER JOIN ( -- Compute Metrics via Expressions @@ -25,9 +27,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + metric_time__day + ) subq_14 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -37,7 +46,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_13 ON - DATE_SUB(CAST(subq_15.ds AS DATETIME), INTERVAL 5 day) = subq_13.metric_time__day + DATE_SUB(CAST(subq_14.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_13.metric_time__day GROUP BY metric_time__day ) subq_19 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0.sql index b79fd59f9b..c3627fb747 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0.sql @@ -15,8 +15,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATETIME_TRUNC(subq_10.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_10 + GROUP BY + metric_time__day ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -142,8 +144,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + metric_time__day ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0_optimized.sql index 1dc4da26fc..eef8d2c6a9 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -10,9 +10,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day + subq_22.metric_time__day AS metric_time__day , subq_21.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_23 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_23 + GROUP BY + metric_time__day + ) subq_22 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,9 +31,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.ds AS metric_time__day + subq_15.metric_time__day AS metric_time__day , SUM(subq_14.bookings) AS bookings - FROM ***************************.mf_time_spine subq_16 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + GROUP BY + metric_time__day + ) subq_15 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -36,13 +50,13 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_14 ON - DATE_SUB(CAST(subq_16.ds AS DATETIME), INTERVAL 5 day) = subq_14.metric_time__day + DATE_SUB(CAST(subq_15.metric_time__day AS DATETIME), INTERVAL 5 day) = subq_14.metric_time__day GROUP BY metric_time__day ) subq_20 ) subq_21 ON - DATE_SUB(CAST(subq_23.ds AS DATETIME), INTERVAL 2 day) = subq_21.metric_time__day + DATE_SUB(CAST(subq_22.metric_time__day AS DATETIME), INTERVAL 2 day) = subq_21.metric_time__day ) subq_24 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' ) subq_25 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index 2ecd5d35b3..957ddf16ee 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -133,8 +133,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + metric_time__day ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index cdef6c0de0..23091b99f2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -14,10 +14,17 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__month', 'metric_time__day'] SELECT - subq_13.ds AS metric_time__day - , DATETIME_TRUNC(subq_13.ds, month) AS metric_time__month + subq_12.metric_time__day AS metric_time__day + , DATETIME_TRUNC(subq_12.metric_time__day, month) AS metric_time__month , subq_11.bookings AS bookings - FROM ***************************.mf_time_spine subq_13 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_13 + GROUP BY + metric_time__day + ) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -27,8 +34,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_11 ON - DATETIME_TRUNC(subq_13.ds, month) = subq_11.metric_time__day - WHERE DATETIME_TRUNC(subq_13.ds, month) = subq_13.ds + DATETIME_TRUNC(subq_12.metric_time__day, month) = subq_11.metric_time__day + WHERE DATETIME_TRUNC(subq_12.metric_time__day, month) = subq_12.metric_time__day ) subq_15 WHERE metric_time__day = '2020-01-01' GROUP BY diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_multiple_granularities__plan0.sql index e9ec5732eb..bbc55a109b 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_multiple_granularities__plan0.sql @@ -129,8 +129,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + metric_time__day ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql index de07009dad..1f06125956 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql @@ -10,11 +10,18 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day - , DATETIME_TRUNC(subq_11.ds, month) AS metric_time__month - , DATETIME_TRUNC(subq_11.ds, year) AS metric_time__year + subq_10.metric_time__day AS metric_time__day + , DATETIME_TRUNC(subq_10.metric_time__day, month) AS metric_time__month + , DATETIME_TRUNC(subq_10.metric_time__day, year) AS metric_time__year , SUM(subq_9.bookings) AS bookings_start_of_month - FROM ***************************.mf_time_spine subq_11 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_11 + GROUP BY + metric_time__day + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -24,7 +31,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_9 ON - DATETIME_TRUNC(subq_11.ds, month) = subq_9.metric_time__day + DATETIME_TRUNC(subq_10.metric_time__day, month) = subq_9.metric_time__day GROUP BY metric_time__day , metric_time__month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0.sql index 98c2aaf089..887bf8e230 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day + DATETIME_TRUNC(subq_8.ds, day) AS booking__ds__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + booking__ds__day ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql index 158bfbdfa2..afd14102e3 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day + subq_21.booking__ds__day AS booking__ds__day , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS booking__ds__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + booking__ds__day + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,7 +51,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATETIME_TRUNC(subq_22.ds, month) = subq_20.booking__ds__day + DATETIME_TRUNC(subq_21.booking__ds__day, month) = subq_20.booking__ds__day GROUP BY booking__ds__day ) subq_26 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index 663ef82bce..d7e1e53c16 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -139,8 +139,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + metric_time__day ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index 31f0a39d91..848341797c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -20,14 +20,21 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['booking_value', 'metric_time__month', 'metric_time__day'] SELECT - subq_21.ds AS metric_time__day - , DATETIME_TRUNC(subq_21.ds, month) AS metric_time__month + subq_20.metric_time__day AS metric_time__day + , DATETIME_TRUNC(subq_20.metric_time__day, month) AS metric_time__month , bookings_source_src_28000.booking_value AS booking_value - FROM ***************************.mf_time_spine subq_21 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_21 + GROUP BY + metric_time__day + ) subq_20 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATE_SUB(CAST(subq_21.ds AS DATETIME), INTERVAL 1 week) = DATETIME_TRUNC(bookings_source_src_28000.ds, day) + DATE_SUB(CAST(subq_20.metric_time__day AS DATETIME), INTERVAL 1 week) = DATETIME_TRUNC(bookings_source_src_28000.ds, day) ) subq_23 WHERE metric_time__day = '2020-01-01' GROUP BY diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_multiple_granularities__plan0.sql index 1bdeb88919..03b7833bc2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_multiple_granularities__plan0.sql @@ -137,8 +137,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + metric_time__day ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_multiple_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_multiple_granularities__plan0_optimized.sql index a67284e4ba..2bbf67efd4 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_multiple_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_metric_multiple_granularities__plan0_optimized.sql @@ -18,15 +18,22 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , DATETIME_TRUNC(subq_17.ds, month) AS metric_time__month - , DATETIME_TRUNC(subq_17.ds, year) AS metric_time__year + subq_16.metric_time__day AS metric_time__day + , DATETIME_TRUNC(subq_16.metric_time__day, month) AS metric_time__month + , DATETIME_TRUNC(subq_16.metric_time__day, year) AS metric_time__year , SUM(bookings_source_src_28000.booking_value) AS booking_value - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + metric_time__day + ) subq_16 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATE_SUB(CAST(subq_17.ds AS DATETIME), INTERVAL 1 week) = DATETIME_TRUNC(bookings_source_src_28000.ds, day) + DATE_SUB(CAST(subq_16.metric_time__day AS DATETIME), INTERVAL 1 week) = DATETIME_TRUNC(bookings_source_src_28000.ds, day) GROUP BY metric_time__day , metric_time__month diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0.sql index 1fff76a029..3e8547d220 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day + DATETIME_TRUNC(subq_8.ds, day) AS booking__ds__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + booking__ds__day ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0_optimized.sql index 085f915e3c..e31804e502 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_agg_time_dim__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day + subq_21.booking__ds__day AS booking__ds__day , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS booking__ds__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + booking__ds__day + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,7 +51,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_SUB(CAST(subq_22.ds AS DATETIME), INTERVAL 14 day) = subq_20.booking__ds__day + DATE_SUB(CAST(subq_21.booking__ds__day AS DATETIME), INTERVAL 14 day) = subq_20.booking__ds__day GROUP BY booking__ds__day ) subq_26 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0.sql index d97a1ed56d..f25749ebe5 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0.sql @@ -121,9 +121,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_3 WHERE subq_3.ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + metric_time__day ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0_optimized.sql index 7ad43c2901..fba158026e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/BigQuery/test_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -13,9 +13,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATETIME_TRUNC(ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_11 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + metric_time__day ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index 649b310687..adee091f52 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -126,9 +126,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Join Self Over Time Range @@ -234,8 +236,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql index 3c0cf770da..6c69a2b1a3 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -14,23 +14,32 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_18 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + DATE_TRUNC('day', ds) ) subq_17 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_15.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_14.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_15.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_14.metric_time__day) ) ) subq_16 ON diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql index 2e940367ea..9f83256743 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index aa15f38c06..8606ce0b97 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day + DATE_TRUNC('month', subq_21.metric_time__day) = subq_20.metric_time__day GROUP BY - subq_22.ds + subq_21.metric_time__day ) subq_26 ON subq_18.metric_time__day = subq_26.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index 9dc762a3e9..13960309cb 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index 808ffc27a1..ec1a53ac20 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('week', subq_22.ds) AS metric_time__week + DATE_TRUNC('week', subq_21.metric_time__day) AS metric_time__week , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,10 +51,10 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day - WHERE DATE_TRUNC('week', subq_22.ds) = subq_22.ds + DATE_TRUNC('month', subq_21.metric_time__day) = subq_20.metric_time__day + WHERE DATE_TRUNC('week', subq_21.metric_time__day) = subq_21.metric_time__day GROUP BY - DATE_TRUNC('week', subq_22.ds) + DATE_TRUNC('week', subq_21.metric_time__day) ) subq_26 ON subq_18.metric_time__week = subq_26.metric_time__week diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql index 88329d00d3..ade5baec3d 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0_optimized.sql index 8eb8c6cbf9..4e47754296 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATEADD(day, -14, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -14, subq_21.metric_time__day) = subq_20.metric_time__day GROUP BY - subq_22.ds + subq_21.metric_time__day ) subq_26 ON subq_18.metric_time__day = subq_26.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 0b40670060..fc901d9013 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index 7024c46d3a..474f3c3585 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('quarter', subq_22.ds) AS metric_time__quarter + DATE_TRUNC('quarter', subq_21.metric_time__day) AS metric_time__quarter , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATEADD(day, -14, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -14, subq_21.metric_time__day) = subq_20.metric_time__day GROUP BY - DATE_TRUNC('quarter', subq_22.ds) + DATE_TRUNC('quarter', subq_21.metric_time__day) ) subq_26 ON subq_18.metric_time__quarter = subq_26.metric_time__quarter diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 49d4478446..83e5489de8 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -127,8 +127,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' @@ -452,8 +454,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day + DATE_TRUNC('day', subq_11.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', subq_11.ds) ) subq_10 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 3e62b59a02..bdab587453 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -14,9 +14,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_20.ds AS metric_time__day + subq_19.metric_time__day AS metric_time__day , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_19 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -26,9 +33,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_18 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day + DATE_TRUNC('month', subq_19.metric_time__day) = subq_18.metric_time__day GROUP BY - subq_20.ds + subq_19.metric_time__day ) subq_24 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -36,9 +43,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day + subq_27.metric_time__day AS metric_time__day , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_28 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -48,9 +62,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_26 ON - DATEADD(month, -1, subq_28.ds) = subq_26.metric_time__day + DATEADD(month, -1, subq_27.metric_time__day) = subq_26.metric_time__day GROUP BY - subq_28.ds + subq_27.metric_time__day ) subq_32 ON subq_24.metric_time__day = subq_32.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index 5f1bfa202f..917acd0754 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -127,8 +127,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' @@ -453,8 +455,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day + DATE_TRUNC('day', subq_11.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', subq_11.ds) ) subq_10 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index a0e28f6a63..90472faa51 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -14,9 +14,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_20.ds) AS metric_time__year + DATE_TRUNC('year', subq_19.metric_time__day) AS metric_time__year , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_19 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -26,10 +33,10 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_18 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day - WHERE DATE_TRUNC('year', subq_20.ds) = subq_20.ds + DATE_TRUNC('month', subq_19.metric_time__day) = subq_18.metric_time__day + WHERE DATE_TRUNC('year', subq_19.metric_time__day) = subq_19.metric_time__day GROUP BY - DATE_TRUNC('year', subq_20.ds) + DATE_TRUNC('year', subq_19.metric_time__day) ) subq_24 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -37,9 +44,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_28.ds) AS metric_time__year + DATE_TRUNC('year', subq_27.metric_time__day) AS metric_time__year , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_28 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -49,9 +63,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_26 ON - DATEADD(month, -1, subq_28.ds) = subq_26.metric_time__day + DATEADD(month, -1, subq_27.metric_time__day) = subq_26.metric_time__day GROUP BY - DATE_TRUNC('year', subq_28.ds) + DATE_TRUNC('year', subq_27.metric_time__day) ) subq_32 ON subq_24.metric_time__year = subq_32.metric_time__year diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index e7137cfe83..5717232d1f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -354,8 +354,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day + DATE_TRUNC('day', subq_9.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_9 + GROUP BY + DATE_TRUNC('day', subq_9.ds) ) subq_8 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql index 6e1e08a67e..f84cddd850 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql @@ -39,9 +39,16 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_25.ds AS metric_time__day + subq_24.metric_time__day AS metric_time__day , subq_23.bookings AS bookings - FROM ***************************.mf_time_spine subq_25 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_25 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -51,7 +58,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_23 ON - DATEADD(day, -14, subq_25.ds) = subq_23.metric_time__day + DATEADD(day, -14, subq_24.metric_time__day) = subq_23.metric_time__day ) subq_27 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0.sql index 8f195e3850..966c5e81e7 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0.sql @@ -121,8 +121,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Join Self Over Time Range @@ -228,8 +230,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0_optimized.sql index 8be396c4a4..6c11a5e462 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -8,26 +8,40 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day + subq_16.metric_time__day AS metric_time__day , COUNT(DISTINCT subq_15.bookers) AS every_2_days_bookers_2_days_ago - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_14.ds AS metric_time__day + subq_13.metric_time__day AS metric_time__day , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_14 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_13 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_14.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_13.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_14.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_13.metric_time__day) ) ) subq_15 ON - DATEADD(day, -2, subq_17.ds) = subq_15.metric_time__day + DATEADD(day, -2, subq_16.metric_time__day) = subq_15.metric_time__day GROUP BY - subq_17.ds + subq_16.metric_time__day ) subq_21 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0.sql index 97ea5f3d65..5529ee4c54 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -127,8 +127,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS booking__ds__day + DATE_TRUNC('day', subq_3.ds) AS booking__ds__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql index 1a7e109f05..5b51521c01 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql @@ -14,15 +14,22 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS booking__ds__day + subq_16.booking__ds__day AS booking__ds__day , SUM(bookings_source_src_28000.booking_value) AS booking_value - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATEADD(week, -1, subq_17.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) + DATEADD(week, -1, subq_16.booking__ds__day) = DATE_TRUNC('day', bookings_source_src_28000.ds) GROUP BY - subq_17.ds + subq_16.booking__ds__day ) subq_21 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0.sql index 52482d8b59..a0abf83a1d 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -121,8 +121,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index 60bbd4728c..43450c782d 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -8,9 +8,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day + subq_10.metric_time__day AS metric_time__day , SUM(subq_9.bookings) AS bookings_5_days_ago - FROM ***************************.mf_time_spine subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -20,7 +27,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_9 ON - DATEADD(day, -5, subq_11.ds) = subq_9.metric_time__day + DATEADD(day, -5, subq_10.metric_time__day) = subq_9.metric_time__day GROUP BY - subq_11.ds + subq_10.metric_time__day ) subq_15 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index bbd320ac3b..6e008ad657 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -22,8 +22,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -153,8 +155,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index f53018153d..d075578367 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -11,10 +11,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_24.ds AS metric_time__day + subq_23.metric_time__day AS metric_time__day , subq_22.booking__is_instant AS booking__is_instant , subq_22.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_24 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_24 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_23 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -27,10 +34,17 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day + subq_16.metric_time__day AS metric_time__day , subq_15.booking__is_instant AS booking__is_instant , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -41,14 +55,14 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_15 ON - DATEADD(day, -5, subq_17.ds) = subq_15.metric_time__day + DATEADD(day, -5, subq_16.metric_time__day) = subq_15.metric_time__day GROUP BY - subq_17.ds + subq_16.metric_time__day , subq_15.booking__is_instant ) subq_21 ) subq_22 ON - DATEADD(day, -2, subq_24.ds) = subq_22.metric_time__day + DATEADD(day, -2, subq_23.metric_time__day) = subq_22.metric_time__day ) subq_25 WHERE booking__is_instant ) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql index 8a2b5f5f8f..1e9c3e6729 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql @@ -16,8 +16,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day + DATE_TRUNC('day', subq_7.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_7 + GROUP BY + DATE_TRUNC('day', subq_7.ds) ) subq_6 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql index b10c0ed06c..9683308f28 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql @@ -11,9 +11,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day + subq_22.metric_time__day AS metric_time__day , subq_21.booking_fees_start_of_month AS booking_fees_start_of_month - FROM ***************************.mf_time_spine subq_23 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_23 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_22 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -34,7 +41,7 @@ FROM ( ) subq_20 ) subq_21 ON - DATE_TRUNC('month', subq_23.ds) = subq_21.metric_time__day + DATE_TRUNC('month', subq_22.metric_time__day) = subq_21.metric_time__day ) subq_24 FULL OUTER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets__plan0.sql index a692b115a4..835723e739 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -137,8 +139,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets__plan0_optimized.sql index d392a13fcc..5fe4ebcf07 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets__plan0_optimized.sql @@ -5,9 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , subq_20.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -19,9 +26,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -31,11 +45,11 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_13 ON - DATEADD(day, -5, subq_15.ds) = subq_13.metric_time__day + DATEADD(day, -5, subq_14.metric_time__day) = subq_13.metric_time__day GROUP BY - subq_15.ds + subq_14.metric_time__day ) subq_19 ) subq_20 ON - DATEADD(day, -2, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -2, subq_21.metric_time__day) = subq_20.metric_time__day ) subq_23 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_time_constraint__plan0.sql index bf1783afa1..db22875610 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_time_constraint__plan0.sql @@ -10,9 +10,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 WHERE subq_10.ds BETWEEN '2020-01-12' AND '2020-01-13' + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -138,8 +140,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_time_constraint__plan0_optimized.sql index 5ce260e750..56e779cde6 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -10,9 +10,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_22 WHERE ds BETWEEN '2020-01-12' AND '2020-01-13' + GROUP BY + DATE_TRUNC('day', ds) ) subq_21 INNER JOIN ( -- Compute Metrics via Expressions @@ -25,9 +27,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -37,9 +46,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_13 ON - DATEADD(day, -5, subq_15.ds) = subq_13.metric_time__day + DATEADD(day, -5, subq_14.metric_time__day) = subq_13.metric_time__day GROUP BY - subq_15.ds + subq_14.metric_time__day ) subq_19 ) subq_20 ON diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_where_constraint__plan0.sql index bb78281744..dc739866cf 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_where_constraint__plan0.sql @@ -15,8 +15,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -142,8 +144,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_where_constraint__plan0_optimized.sql index 76818b62f5..46537d5f65 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -10,9 +10,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day + subq_22.metric_time__day AS metric_time__day , subq_21.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_23 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_23 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_22 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,9 +31,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.ds AS metric_time__day + subq_15.metric_time__day AS metric_time__day , SUM(subq_14.bookings) AS bookings - FROM ***************************.mf_time_spine subq_16 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_15 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -36,13 +50,13 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_14 ON - DATEADD(day, -5, subq_16.ds) = subq_14.metric_time__day + DATEADD(day, -5, subq_15.metric_time__day) = subq_14.metric_time__day GROUP BY - subq_16.ds + subq_15.metric_time__day ) subq_20 ) subq_21 ON - DATEADD(day, -2, subq_23.ds) = subq_21.metric_time__day + DATEADD(day, -2, subq_22.metric_time__day) = subq_21.metric_time__day ) subq_24 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' ) subq_25 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index 4111729e97..93b0ffe384 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -133,8 +133,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index bfd3b8fbce..3b3ab93020 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -14,10 +14,17 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__month', 'metric_time__day'] SELECT - subq_13.ds AS metric_time__day - , DATE_TRUNC('month', subq_13.ds) AS metric_time__month + subq_12.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_12.metric_time__day) AS metric_time__month , subq_11.bookings AS bookings - FROM ***************************.mf_time_spine subq_13 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_13 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -27,8 +34,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_11 ON - DATE_TRUNC('month', subq_13.ds) = subq_11.metric_time__day - WHERE DATE_TRUNC('month', subq_13.ds) = subq_13.ds + DATE_TRUNC('month', subq_12.metric_time__day) = subq_11.metric_time__day + WHERE DATE_TRUNC('month', subq_12.metric_time__day) = subq_12.metric_time__day ) subq_15 WHERE metric_time__day = '2020-01-01' GROUP BY diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_multiple_granularities__plan0.sql index cf8bea400b..a5d0cc4614 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_multiple_granularities__plan0.sql @@ -129,8 +129,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql index 76767e46c6..e8bea713fe 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql @@ -10,11 +10,18 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day - , DATE_TRUNC('month', subq_11.ds) AS metric_time__month - , DATE_TRUNC('year', subq_11.ds) AS metric_time__year + subq_10.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_10.metric_time__day) AS metric_time__month + , DATE_TRUNC('year', subq_10.metric_time__day) AS metric_time__year , SUM(subq_9.bookings) AS bookings_start_of_month - FROM ***************************.mf_time_spine subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -24,9 +31,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_9 ON - DATE_TRUNC('month', subq_11.ds) = subq_9.metric_time__day + DATE_TRUNC('month', subq_10.metric_time__day) = subq_9.metric_time__day GROUP BY - subq_11.ds - , DATE_TRUNC('month', subq_11.ds) - , DATE_TRUNC('year', subq_11.ds) + subq_10.metric_time__day + , DATE_TRUNC('month', subq_10.metric_time__day) + , DATE_TRUNC('year', subq_10.metric_time__day) ) subq_15 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0.sql index 0b46e69070..b9c84a352d 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day + DATE_TRUNC('day', subq_8.ds) AS booking__ds__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql index 87a86d9826..817001782a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day + subq_21.booking__ds__day AS booking__ds__day , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS booking__ds__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.booking__ds__day + DATE_TRUNC('month', subq_21.booking__ds__day) = subq_20.booking__ds__day GROUP BY - subq_22.ds + subq_21.booking__ds__day ) subq_26 ON subq_18.booking__ds__day = subq_26.booking__ds__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index 04e5e6ec5e..6825b1515a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -139,8 +139,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index da44e813f4..3d915776f9 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -20,14 +20,21 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['booking_value', 'metric_time__month', 'metric_time__day'] SELECT - subq_21.ds AS metric_time__day - , DATE_TRUNC('month', subq_21.ds) AS metric_time__month + subq_20.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_20.metric_time__day) AS metric_time__month , bookings_source_src_28000.booking_value AS booking_value - FROM ***************************.mf_time_spine subq_21 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_21 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_20 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATEADD(week, -1, subq_21.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) + DATEADD(week, -1, subq_20.metric_time__day) = DATE_TRUNC('day', bookings_source_src_28000.ds) ) subq_23 WHERE metric_time__day = '2020-01-01' GROUP BY diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_multiple_granularities__plan0.sql index a356026025..6953aa2f21 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_multiple_granularities__plan0.sql @@ -137,8 +137,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_multiple_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_multiple_granularities__plan0_optimized.sql index 58b1be36eb..bf18d991fe 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_multiple_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_metric_multiple_granularities__plan0_optimized.sql @@ -18,19 +18,26 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , DATE_TRUNC('month', subq_17.ds) AS metric_time__month - , DATE_TRUNC('year', subq_17.ds) AS metric_time__year + subq_16.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_16.metric_time__day) AS metric_time__month + , DATE_TRUNC('year', subq_16.metric_time__day) AS metric_time__year , SUM(bookings_source_src_28000.booking_value) AS booking_value - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATEADD(week, -1, subq_17.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) + DATEADD(week, -1, subq_16.metric_time__day) = DATE_TRUNC('day', bookings_source_src_28000.ds) GROUP BY - subq_17.ds - , DATE_TRUNC('month', subq_17.ds) - , DATE_TRUNC('year', subq_17.ds) + subq_16.metric_time__day + , DATE_TRUNC('month', subq_16.metric_time__day) + , DATE_TRUNC('year', subq_16.metric_time__day) ) subq_21 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_agg_time_dim__plan0.sql index ea02464b08..38c315248c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_agg_time_dim__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day + DATE_TRUNC('day', subq_8.ds) AS booking__ds__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_agg_time_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_agg_time_dim__plan0_optimized.sql index 82e7a89339..a9c72b80f2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_agg_time_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_agg_time_dim__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day + subq_21.booking__ds__day AS booking__ds__day , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS booking__ds__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATEADD(day, -14, subq_22.ds) = subq_20.booking__ds__day + DATEADD(day, -14, subq_21.booking__ds__day) = subq_20.booking__ds__day GROUP BY - subq_22.ds + subq_21.booking__ds__day ) subq_26 ON subq_18.booking__ds__day = subq_26.booking__ds__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0.sql index a5f6c92502..69a23479a6 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0.sql @@ -121,9 +121,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 WHERE subq_3.ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0_optimized.sql index ba6c53ac37..a02bba01aa 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Databricks/test_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -13,9 +13,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + DATE_TRUNC('day', ds) ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index 7922d7265d..b8504f22d4 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -126,9 +126,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Join Self Over Time Range @@ -234,8 +236,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql index e59b680106..97bc1f14d8 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -14,23 +14,32 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_18 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + DATE_TRUNC('day', ds) ) subq_17 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_15.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_14.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > subq_15.ds - MAKE_INTERVAL(days => 2) + DATE_TRUNC('day', bookings_source_src_28000.ds) > subq_14.metric_time__day - MAKE_INTERVAL(days => 2) ) ) subq_16 ON diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql index a9d3e6d977..c5e4c8f4f2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index aa15f38c06..8606ce0b97 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day + DATE_TRUNC('month', subq_21.metric_time__day) = subq_20.metric_time__day GROUP BY - subq_22.ds + subq_21.metric_time__day ) subq_26 ON subq_18.metric_time__day = subq_26.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index eb72ea9213..b5b64053b3 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index 808ffc27a1..ec1a53ac20 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('week', subq_22.ds) AS metric_time__week + DATE_TRUNC('week', subq_21.metric_time__day) AS metric_time__week , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,10 +51,10 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day - WHERE DATE_TRUNC('week', subq_22.ds) = subq_22.ds + DATE_TRUNC('month', subq_21.metric_time__day) = subq_20.metric_time__day + WHERE DATE_TRUNC('week', subq_21.metric_time__day) = subq_21.metric_time__day GROUP BY - DATE_TRUNC('week', subq_22.ds) + DATE_TRUNC('week', subq_21.metric_time__day) ) subq_26 ON subq_18.metric_time__week = subq_26.metric_time__week diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql index c38796f09c..f25c74a941 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0_optimized.sql index 33e8eda544..4365abeb26 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - subq_22.ds - MAKE_INTERVAL(days => 14) = subq_20.metric_time__day + subq_21.metric_time__day - MAKE_INTERVAL(days => 14) = subq_20.metric_time__day GROUP BY - subq_22.ds + subq_21.metric_time__day ) subq_26 ON subq_18.metric_time__day = subq_26.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql index fbae91f2a9..6cbf458a6e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index 91c4a4a2c5..d33f33dc62 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('quarter', subq_22.ds) AS metric_time__quarter + DATE_TRUNC('quarter', subq_21.metric_time__day) AS metric_time__quarter , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - subq_22.ds - MAKE_INTERVAL(days => 14) = subq_20.metric_time__day + subq_21.metric_time__day - MAKE_INTERVAL(days => 14) = subq_20.metric_time__day GROUP BY - DATE_TRUNC('quarter', subq_22.ds) + DATE_TRUNC('quarter', subq_21.metric_time__day) ) subq_26 ON subq_18.metric_time__quarter = subq_26.metric_time__quarter diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 178cf2de2a..5dfd0f0ec0 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -127,8 +127,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' @@ -452,8 +454,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day + DATE_TRUNC('day', subq_11.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', subq_11.ds) ) subq_10 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 8ea8e07a76..643587a0c2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -14,9 +14,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_20.ds AS metric_time__day + subq_19.metric_time__day AS metric_time__day , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_19 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -26,9 +33,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_18 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day + DATE_TRUNC('month', subq_19.metric_time__day) = subq_18.metric_time__day GROUP BY - subq_20.ds + subq_19.metric_time__day ) subq_24 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -36,9 +43,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day + subq_27.metric_time__day AS metric_time__day , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_28 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -48,9 +62,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_26 ON - subq_28.ds - MAKE_INTERVAL(months => 1) = subq_26.metric_time__day + subq_27.metric_time__day - MAKE_INTERVAL(months => 1) = subq_26.metric_time__day GROUP BY - subq_28.ds + subq_27.metric_time__day ) subq_32 ON subq_24.metric_time__day = subq_32.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index d50cfe18d9..aaa36310ef 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -127,8 +127,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' @@ -453,8 +455,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day + DATE_TRUNC('day', subq_11.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', subq_11.ds) ) subq_10 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 41dbd9a78a..8d545b2f4b 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -14,9 +14,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_20.ds) AS metric_time__year + DATE_TRUNC('year', subq_19.metric_time__day) AS metric_time__year , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_19 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -26,10 +33,10 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_18 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day - WHERE DATE_TRUNC('year', subq_20.ds) = subq_20.ds + DATE_TRUNC('month', subq_19.metric_time__day) = subq_18.metric_time__day + WHERE DATE_TRUNC('year', subq_19.metric_time__day) = subq_19.metric_time__day GROUP BY - DATE_TRUNC('year', subq_20.ds) + DATE_TRUNC('year', subq_19.metric_time__day) ) subq_24 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -37,9 +44,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_28.ds) AS metric_time__year + DATE_TRUNC('year', subq_27.metric_time__day) AS metric_time__year , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_28 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -49,9 +63,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_26 ON - subq_28.ds - MAKE_INTERVAL(months => 1) = subq_26.metric_time__day + subq_27.metric_time__day - MAKE_INTERVAL(months => 1) = subq_26.metric_time__day GROUP BY - DATE_TRUNC('year', subq_28.ds) + DATE_TRUNC('year', subq_27.metric_time__day) ) subq_32 ON subq_24.metric_time__year = subq_32.metric_time__year diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 0fd450ec32..1c2c9b8ca7 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -354,8 +354,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day + DATE_TRUNC('day', subq_9.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_9 + GROUP BY + DATE_TRUNC('day', subq_9.ds) ) subq_8 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql index 9a52bdd33f..61cf46ca06 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql @@ -39,9 +39,16 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_25.ds AS metric_time__day + subq_24.metric_time__day AS metric_time__day , subq_23.bookings AS bookings - FROM ***************************.mf_time_spine subq_25 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_25 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -51,7 +58,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_23 ON - subq_25.ds - MAKE_INTERVAL(days => 14) = subq_23.metric_time__day + subq_24.metric_time__day - MAKE_INTERVAL(days => 14) = subq_23.metric_time__day ) subq_27 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0.sql index 6d78aa9c64..9c8fbff1b5 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0.sql @@ -121,8 +121,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Join Self Over Time Range @@ -228,8 +230,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0_optimized.sql index bbe67a8031..64d611d740 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -8,26 +8,40 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day + subq_16.metric_time__day AS metric_time__day , COUNT(DISTINCT subq_15.bookers) AS every_2_days_bookers_2_days_ago - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_14.ds AS metric_time__day + subq_13.metric_time__day AS metric_time__day , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_14 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_13 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_14.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_13.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > subq_14.ds - MAKE_INTERVAL(days => 2) + DATE_TRUNC('day', bookings_source_src_28000.ds) > subq_13.metric_time__day - MAKE_INTERVAL(days => 2) ) ) subq_15 ON - subq_17.ds - MAKE_INTERVAL(days => 2) = subq_15.metric_time__day + subq_16.metric_time__day - MAKE_INTERVAL(days => 2) = subq_15.metric_time__day GROUP BY - subq_17.ds + subq_16.metric_time__day ) subq_21 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0.sql index cc025f4b8c..52bd0d4e48 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -127,8 +127,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS booking__ds__day + DATE_TRUNC('day', subq_3.ds) AS booking__ds__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql index 57163ee2cc..8662e7018d 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql @@ -14,15 +14,22 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS booking__ds__day + subq_16.booking__ds__day AS booking__ds__day , SUM(bookings_source_src_28000.booking_value) AS booking_value - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - subq_17.ds - MAKE_INTERVAL(weeks => 1) = DATE_TRUNC('day', bookings_source_src_28000.ds) + subq_16.booking__ds__day - MAKE_INTERVAL(weeks => 1) = DATE_TRUNC('day', bookings_source_src_28000.ds) GROUP BY - subq_17.ds + subq_16.booking__ds__day ) subq_21 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0.sql index bbb49e0a31..833a0be810 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -121,8 +121,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index d66bd748ee..1d3a913a96 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -8,9 +8,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day + subq_10.metric_time__day AS metric_time__day , SUM(subq_9.bookings) AS bookings_5_days_ago - FROM ***************************.mf_time_spine subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -20,7 +27,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_9 ON - subq_11.ds - MAKE_INTERVAL(days => 5) = subq_9.metric_time__day + subq_10.metric_time__day - MAKE_INTERVAL(days => 5) = subq_9.metric_time__day GROUP BY - subq_11.ds + subq_10.metric_time__day ) subq_15 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index 13cc66980b..f75b40693f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -22,8 +22,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -153,8 +155,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index 8b21f2c359..f24a23346b 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -11,10 +11,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_24.ds AS metric_time__day + subq_23.metric_time__day AS metric_time__day , subq_22.booking__is_instant AS booking__is_instant , subq_22.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_24 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_24 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_23 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -27,10 +34,17 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day + subq_16.metric_time__day AS metric_time__day , subq_15.booking__is_instant AS booking__is_instant , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -41,14 +55,14 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_15 ON - subq_17.ds - MAKE_INTERVAL(days => 5) = subq_15.metric_time__day + subq_16.metric_time__day - MAKE_INTERVAL(days => 5) = subq_15.metric_time__day GROUP BY - subq_17.ds + subq_16.metric_time__day , subq_15.booking__is_instant ) subq_21 ) subq_22 ON - subq_24.ds - MAKE_INTERVAL(days => 2) = subq_22.metric_time__day + subq_23.metric_time__day - MAKE_INTERVAL(days => 2) = subq_22.metric_time__day ) subq_25 WHERE booking__is_instant ) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql index 5ac836a079..34d9a5b8a6 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql @@ -16,8 +16,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day + DATE_TRUNC('day', subq_7.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_7 + GROUP BY + DATE_TRUNC('day', subq_7.ds) ) subq_6 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql index b10c0ed06c..9683308f28 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql @@ -11,9 +11,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day + subq_22.metric_time__day AS metric_time__day , subq_21.booking_fees_start_of_month AS booking_fees_start_of_month - FROM ***************************.mf_time_spine subq_23 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_23 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_22 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -34,7 +41,7 @@ FROM ( ) subq_20 ) subq_21 ON - DATE_TRUNC('month', subq_23.ds) = subq_21.metric_time__day + DATE_TRUNC('month', subq_22.metric_time__day) = subq_21.metric_time__day ) subq_24 FULL OUTER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets__plan0.sql index 86b254f0a9..1581a10b2f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -137,8 +139,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets__plan0_optimized.sql index f31f2877a4..bedee962f8 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets__plan0_optimized.sql @@ -5,9 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , subq_20.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -19,9 +26,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -31,11 +45,11 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_13 ON - subq_15.ds - MAKE_INTERVAL(days => 5) = subq_13.metric_time__day + subq_14.metric_time__day - MAKE_INTERVAL(days => 5) = subq_13.metric_time__day GROUP BY - subq_15.ds + subq_14.metric_time__day ) subq_19 ) subq_20 ON - subq_22.ds - MAKE_INTERVAL(days => 2) = subq_20.metric_time__day + subq_21.metric_time__day - MAKE_INTERVAL(days => 2) = subq_20.metric_time__day ) subq_23 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_time_constraint__plan0.sql index bdba4860e0..c83baf543a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_time_constraint__plan0.sql @@ -10,9 +10,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 WHERE subq_10.ds BETWEEN '2020-01-12' AND '2020-01-13' + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -138,8 +140,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_time_constraint__plan0_optimized.sql index b8209c2676..32817c3c0c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -10,9 +10,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_22 WHERE ds BETWEEN '2020-01-12' AND '2020-01-13' + GROUP BY + DATE_TRUNC('day', ds) ) subq_21 INNER JOIN ( -- Compute Metrics via Expressions @@ -25,9 +27,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -37,9 +46,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_13 ON - subq_15.ds - MAKE_INTERVAL(days => 5) = subq_13.metric_time__day + subq_14.metric_time__day - MAKE_INTERVAL(days => 5) = subq_13.metric_time__day GROUP BY - subq_15.ds + subq_14.metric_time__day ) subq_19 ) subq_20 ON diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_where_constraint__plan0.sql index 777ebd13a2..10874da024 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_where_constraint__plan0.sql @@ -15,8 +15,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -142,8 +144,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_where_constraint__plan0_optimized.sql index 77718a3822..f22105103f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -10,9 +10,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day + subq_22.metric_time__day AS metric_time__day , subq_21.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_23 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_23 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_22 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,9 +31,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.ds AS metric_time__day + subq_15.metric_time__day AS metric_time__day , SUM(subq_14.bookings) AS bookings - FROM ***************************.mf_time_spine subq_16 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_15 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -36,13 +50,13 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_14 ON - subq_16.ds - MAKE_INTERVAL(days => 5) = subq_14.metric_time__day + subq_15.metric_time__day - MAKE_INTERVAL(days => 5) = subq_14.metric_time__day GROUP BY - subq_16.ds + subq_15.metric_time__day ) subq_20 ) subq_21 ON - subq_23.ds - MAKE_INTERVAL(days => 2) = subq_21.metric_time__day + subq_22.metric_time__day - MAKE_INTERVAL(days => 2) = subq_21.metric_time__day ) subq_24 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' ) subq_25 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index c633e0a0db..ddbc576dcd 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -133,8 +133,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index bfd3b8fbce..3b3ab93020 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -14,10 +14,17 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__month', 'metric_time__day'] SELECT - subq_13.ds AS metric_time__day - , DATE_TRUNC('month', subq_13.ds) AS metric_time__month + subq_12.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_12.metric_time__day) AS metric_time__month , subq_11.bookings AS bookings - FROM ***************************.mf_time_spine subq_13 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_13 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -27,8 +34,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_11 ON - DATE_TRUNC('month', subq_13.ds) = subq_11.metric_time__day - WHERE DATE_TRUNC('month', subq_13.ds) = subq_13.ds + DATE_TRUNC('month', subq_12.metric_time__day) = subq_11.metric_time__day + WHERE DATE_TRUNC('month', subq_12.metric_time__day) = subq_12.metric_time__day ) subq_15 WHERE metric_time__day = '2020-01-01' GROUP BY diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_multiple_granularities__plan0.sql index 8a62bf7c11..237e290cca 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_multiple_granularities__plan0.sql @@ -129,8 +129,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql index 76767e46c6..e8bea713fe 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql @@ -10,11 +10,18 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day - , DATE_TRUNC('month', subq_11.ds) AS metric_time__month - , DATE_TRUNC('year', subq_11.ds) AS metric_time__year + subq_10.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_10.metric_time__day) AS metric_time__month + , DATE_TRUNC('year', subq_10.metric_time__day) AS metric_time__year , SUM(subq_9.bookings) AS bookings_start_of_month - FROM ***************************.mf_time_spine subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -24,9 +31,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_9 ON - DATE_TRUNC('month', subq_11.ds) = subq_9.metric_time__day + DATE_TRUNC('month', subq_10.metric_time__day) = subq_9.metric_time__day GROUP BY - subq_11.ds - , DATE_TRUNC('month', subq_11.ds) - , DATE_TRUNC('year', subq_11.ds) + subq_10.metric_time__day + , DATE_TRUNC('month', subq_10.metric_time__day) + , DATE_TRUNC('year', subq_10.metric_time__day) ) subq_15 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0.sql index 8734e9a26a..abfd20d6db 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day + DATE_TRUNC('day', subq_8.ds) AS booking__ds__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql index 87a86d9826..817001782a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day + subq_21.booking__ds__day AS booking__ds__day , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS booking__ds__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.booking__ds__day + DATE_TRUNC('month', subq_21.booking__ds__day) = subq_20.booking__ds__day GROUP BY - subq_22.ds + subq_21.booking__ds__day ) subq_26 ON subq_18.booking__ds__day = subq_26.booking__ds__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index 6c5dc6b093..e781d6349e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -139,8 +139,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index f83880110c..2ccbc4dc1f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -20,14 +20,21 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['booking_value', 'metric_time__month', 'metric_time__day'] SELECT - subq_21.ds AS metric_time__day - , DATE_TRUNC('month', subq_21.ds) AS metric_time__month + subq_20.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_20.metric_time__day) AS metric_time__month , bookings_source_src_28000.booking_value AS booking_value - FROM ***************************.mf_time_spine subq_21 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_21 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_20 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - subq_21.ds - MAKE_INTERVAL(weeks => 1) = DATE_TRUNC('day', bookings_source_src_28000.ds) + subq_20.metric_time__day - MAKE_INTERVAL(weeks => 1) = DATE_TRUNC('day', bookings_source_src_28000.ds) ) subq_23 WHERE metric_time__day = '2020-01-01' GROUP BY diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_multiple_granularities__plan0.sql index 8a46329ece..db202ec988 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_multiple_granularities__plan0.sql @@ -137,8 +137,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_multiple_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_multiple_granularities__plan0_optimized.sql index d13f6c1eee..6162d30a23 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_multiple_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_metric_multiple_granularities__plan0_optimized.sql @@ -18,19 +18,26 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , DATE_TRUNC('month', subq_17.ds) AS metric_time__month - , DATE_TRUNC('year', subq_17.ds) AS metric_time__year + subq_16.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_16.metric_time__day) AS metric_time__month + , DATE_TRUNC('year', subq_16.metric_time__day) AS metric_time__year , SUM(bookings_source_src_28000.booking_value) AS booking_value - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - subq_17.ds - MAKE_INTERVAL(weeks => 1) = DATE_TRUNC('day', bookings_source_src_28000.ds) + subq_16.metric_time__day - MAKE_INTERVAL(weeks => 1) = DATE_TRUNC('day', bookings_source_src_28000.ds) GROUP BY - subq_17.ds - , DATE_TRUNC('month', subq_17.ds) - , DATE_TRUNC('year', subq_17.ds) + subq_16.metric_time__day + , DATE_TRUNC('month', subq_16.metric_time__day) + , DATE_TRUNC('year', subq_16.metric_time__day) ) subq_21 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_agg_time_dim__plan0.sql index a7b8e46f66..68b415cf6d 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_agg_time_dim__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day + DATE_TRUNC('day', subq_8.ds) AS booking__ds__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_agg_time_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_agg_time_dim__plan0_optimized.sql index 284d3fc1f5..1bade7770a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_agg_time_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_agg_time_dim__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day + subq_21.booking__ds__day AS booking__ds__day , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS booking__ds__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - subq_22.ds - MAKE_INTERVAL(days => 14) = subq_20.booking__ds__day + subq_21.booking__ds__day - MAKE_INTERVAL(days => 14) = subq_20.booking__ds__day GROUP BY - subq_22.ds + subq_21.booking__ds__day ) subq_26 ON subq_18.booking__ds__day = subq_26.booking__ds__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0.sql index ca0633f023..3c2af9dafb 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0.sql @@ -121,9 +121,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 WHERE subq_3.ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0_optimized.sql index 9a34957a36..16dd6d6060 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Postgres/test_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -13,9 +13,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + DATE_TRUNC('day', ds) ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index 946587cdba..16e1158cb0 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -126,9 +126,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Join Self Over Time Range @@ -234,8 +236,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql index 3c0cf770da..6c69a2b1a3 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -14,23 +14,32 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_18 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + DATE_TRUNC('day', ds) ) subq_17 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_15.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_14.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_15.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_14.metric_time__day) ) ) subq_16 ON diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql index 87688d112e..0fad1c8ab8 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index aa15f38c06..8606ce0b97 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day + DATE_TRUNC('month', subq_21.metric_time__day) = subq_20.metric_time__day GROUP BY - subq_22.ds + subq_21.metric_time__day ) subq_26 ON subq_18.metric_time__day = subq_26.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index be71703b1c..6b4679a6be 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index 808ffc27a1..ec1a53ac20 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('week', subq_22.ds) AS metric_time__week + DATE_TRUNC('week', subq_21.metric_time__day) AS metric_time__week , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,10 +51,10 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day - WHERE DATE_TRUNC('week', subq_22.ds) = subq_22.ds + DATE_TRUNC('month', subq_21.metric_time__day) = subq_20.metric_time__day + WHERE DATE_TRUNC('week', subq_21.metric_time__day) = subq_21.metric_time__day GROUP BY - DATE_TRUNC('week', subq_22.ds) + DATE_TRUNC('week', subq_21.metric_time__day) ) subq_26 ON subq_18.metric_time__week = subq_26.metric_time__week diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql index a29a832f2d..ec4f864af4 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0_optimized.sql index 8eb8c6cbf9..4e47754296 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATEADD(day, -14, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -14, subq_21.metric_time__day) = subq_20.metric_time__day GROUP BY - subq_22.ds + subq_21.metric_time__day ) subq_26 ON subq_18.metric_time__day = subq_26.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 74fffe4c7f..d191df7af0 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index 7024c46d3a..474f3c3585 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('quarter', subq_22.ds) AS metric_time__quarter + DATE_TRUNC('quarter', subq_21.metric_time__day) AS metric_time__quarter , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATEADD(day, -14, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -14, subq_21.metric_time__day) = subq_20.metric_time__day GROUP BY - DATE_TRUNC('quarter', subq_22.ds) + DATE_TRUNC('quarter', subq_21.metric_time__day) ) subq_26 ON subq_18.metric_time__quarter = subq_26.metric_time__quarter diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 581fd0e789..994e03c112 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -127,8 +127,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' @@ -452,8 +454,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day + DATE_TRUNC('day', subq_11.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', subq_11.ds) ) subq_10 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 3e62b59a02..bdab587453 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -14,9 +14,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_20.ds AS metric_time__day + subq_19.metric_time__day AS metric_time__day , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_19 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -26,9 +33,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_18 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day + DATE_TRUNC('month', subq_19.metric_time__day) = subq_18.metric_time__day GROUP BY - subq_20.ds + subq_19.metric_time__day ) subq_24 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -36,9 +43,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day + subq_27.metric_time__day AS metric_time__day , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_28 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -48,9 +62,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_26 ON - DATEADD(month, -1, subq_28.ds) = subq_26.metric_time__day + DATEADD(month, -1, subq_27.metric_time__day) = subq_26.metric_time__day GROUP BY - subq_28.ds + subq_27.metric_time__day ) subq_32 ON subq_24.metric_time__day = subq_32.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index 4ada8feb60..40327a1231 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -127,8 +127,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' @@ -453,8 +455,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day + DATE_TRUNC('day', subq_11.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', subq_11.ds) ) subq_10 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index a0e28f6a63..90472faa51 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -14,9 +14,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_20.ds) AS metric_time__year + DATE_TRUNC('year', subq_19.metric_time__day) AS metric_time__year , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_19 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -26,10 +33,10 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_18 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day - WHERE DATE_TRUNC('year', subq_20.ds) = subq_20.ds + DATE_TRUNC('month', subq_19.metric_time__day) = subq_18.metric_time__day + WHERE DATE_TRUNC('year', subq_19.metric_time__day) = subq_19.metric_time__day GROUP BY - DATE_TRUNC('year', subq_20.ds) + DATE_TRUNC('year', subq_19.metric_time__day) ) subq_24 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -37,9 +44,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_28.ds) AS metric_time__year + DATE_TRUNC('year', subq_27.metric_time__day) AS metric_time__year , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_28 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -49,9 +63,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_26 ON - DATEADD(month, -1, subq_28.ds) = subq_26.metric_time__day + DATEADD(month, -1, subq_27.metric_time__day) = subq_26.metric_time__day GROUP BY - DATE_TRUNC('year', subq_28.ds) + DATE_TRUNC('year', subq_27.metric_time__day) ) subq_32 ON subq_24.metric_time__year = subq_32.metric_time__year diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 2838e435a1..825271a223 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -354,8 +354,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day + DATE_TRUNC('day', subq_9.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_9 + GROUP BY + DATE_TRUNC('day', subq_9.ds) ) subq_8 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql index 6e1e08a67e..f84cddd850 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql @@ -39,9 +39,16 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_25.ds AS metric_time__day + subq_24.metric_time__day AS metric_time__day , subq_23.bookings AS bookings - FROM ***************************.mf_time_spine subq_25 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_25 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -51,7 +58,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_23 ON - DATEADD(day, -14, subq_25.ds) = subq_23.metric_time__day + DATEADD(day, -14, subq_24.metric_time__day) = subq_23.metric_time__day ) subq_27 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0.sql index 7d11897fc7..f8c91e5d44 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0.sql @@ -121,8 +121,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Join Self Over Time Range @@ -228,8 +230,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0_optimized.sql index 8be396c4a4..6c11a5e462 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -8,26 +8,40 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day + subq_16.metric_time__day AS metric_time__day , COUNT(DISTINCT subq_15.bookers) AS every_2_days_bookers_2_days_ago - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_14.ds AS metric_time__day + subq_13.metric_time__day AS metric_time__day , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_14 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_13 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_14.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_13.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_14.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_13.metric_time__day) ) ) subq_15 ON - DATEADD(day, -2, subq_17.ds) = subq_15.metric_time__day + DATEADD(day, -2, subq_16.metric_time__day) = subq_15.metric_time__day GROUP BY - subq_17.ds + subq_16.metric_time__day ) subq_21 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0.sql index ad6e88183b..2db5cd167b 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -127,8 +127,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS booking__ds__day + DATE_TRUNC('day', subq_3.ds) AS booking__ds__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql index 1a7e109f05..5b51521c01 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql @@ -14,15 +14,22 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS booking__ds__day + subq_16.booking__ds__day AS booking__ds__day , SUM(bookings_source_src_28000.booking_value) AS booking_value - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATEADD(week, -1, subq_17.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) + DATEADD(week, -1, subq_16.booking__ds__day) = DATE_TRUNC('day', bookings_source_src_28000.ds) GROUP BY - subq_17.ds + subq_16.booking__ds__day ) subq_21 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0.sql index 684a0f26a9..93a95b7333 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -121,8 +121,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index 60bbd4728c..43450c782d 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -8,9 +8,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day + subq_10.metric_time__day AS metric_time__day , SUM(subq_9.bookings) AS bookings_5_days_ago - FROM ***************************.mf_time_spine subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -20,7 +27,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_9 ON - DATEADD(day, -5, subq_11.ds) = subq_9.metric_time__day + DATEADD(day, -5, subq_10.metric_time__day) = subq_9.metric_time__day GROUP BY - subq_11.ds + subq_10.metric_time__day ) subq_15 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index 77e4d19248..0607738a05 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -22,8 +22,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -153,8 +155,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index f53018153d..d075578367 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -11,10 +11,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_24.ds AS metric_time__day + subq_23.metric_time__day AS metric_time__day , subq_22.booking__is_instant AS booking__is_instant , subq_22.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_24 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_24 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_23 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -27,10 +34,17 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day + subq_16.metric_time__day AS metric_time__day , subq_15.booking__is_instant AS booking__is_instant , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -41,14 +55,14 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_15 ON - DATEADD(day, -5, subq_17.ds) = subq_15.metric_time__day + DATEADD(day, -5, subq_16.metric_time__day) = subq_15.metric_time__day GROUP BY - subq_17.ds + subq_16.metric_time__day , subq_15.booking__is_instant ) subq_21 ) subq_22 ON - DATEADD(day, -2, subq_24.ds) = subq_22.metric_time__day + DATEADD(day, -2, subq_23.metric_time__day) = subq_22.metric_time__day ) subq_25 WHERE booking__is_instant ) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql index 15a016badb..2ce972422f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql @@ -16,8 +16,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day + DATE_TRUNC('day', subq_7.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_7 + GROUP BY + DATE_TRUNC('day', subq_7.ds) ) subq_6 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql index b10c0ed06c..9683308f28 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql @@ -11,9 +11,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day + subq_22.metric_time__day AS metric_time__day , subq_21.booking_fees_start_of_month AS booking_fees_start_of_month - FROM ***************************.mf_time_spine subq_23 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_23 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_22 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -34,7 +41,7 @@ FROM ( ) subq_20 ) subq_21 ON - DATE_TRUNC('month', subq_23.ds) = subq_21.metric_time__day + DATE_TRUNC('month', subq_22.metric_time__day) = subq_21.metric_time__day ) subq_24 FULL OUTER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets__plan0.sql index 03f4118d5d..6dcf178727 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -137,8 +139,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets__plan0_optimized.sql index d392a13fcc..5fe4ebcf07 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets__plan0_optimized.sql @@ -5,9 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , subq_20.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -19,9 +26,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -31,11 +45,11 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_13 ON - DATEADD(day, -5, subq_15.ds) = subq_13.metric_time__day + DATEADD(day, -5, subq_14.metric_time__day) = subq_13.metric_time__day GROUP BY - subq_15.ds + subq_14.metric_time__day ) subq_19 ) subq_20 ON - DATEADD(day, -2, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -2, subq_21.metric_time__day) = subq_20.metric_time__day ) subq_23 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_time_constraint__plan0.sql index 13ec96fc52..a08f81adb0 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_time_constraint__plan0.sql @@ -10,9 +10,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 WHERE subq_10.ds BETWEEN '2020-01-12' AND '2020-01-13' + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -138,8 +140,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_time_constraint__plan0_optimized.sql index 5ce260e750..56e779cde6 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -10,9 +10,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_22 WHERE ds BETWEEN '2020-01-12' AND '2020-01-13' + GROUP BY + DATE_TRUNC('day', ds) ) subq_21 INNER JOIN ( -- Compute Metrics via Expressions @@ -25,9 +27,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -37,9 +46,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_13 ON - DATEADD(day, -5, subq_15.ds) = subq_13.metric_time__day + DATEADD(day, -5, subq_14.metric_time__day) = subq_13.metric_time__day GROUP BY - subq_15.ds + subq_14.metric_time__day ) subq_19 ) subq_20 ON diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_where_constraint__plan0.sql index 5be47d98a0..ba8caf68b7 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_where_constraint__plan0.sql @@ -15,8 +15,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -142,8 +144,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_where_constraint__plan0_optimized.sql index 76818b62f5..46537d5f65 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -10,9 +10,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day + subq_22.metric_time__day AS metric_time__day , subq_21.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_23 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_23 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_22 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,9 +31,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.ds AS metric_time__day + subq_15.metric_time__day AS metric_time__day , SUM(subq_14.bookings) AS bookings - FROM ***************************.mf_time_spine subq_16 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_15 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -36,13 +50,13 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_14 ON - DATEADD(day, -5, subq_16.ds) = subq_14.metric_time__day + DATEADD(day, -5, subq_15.metric_time__day) = subq_14.metric_time__day GROUP BY - subq_16.ds + subq_15.metric_time__day ) subq_20 ) subq_21 ON - DATEADD(day, -2, subq_23.ds) = subq_21.metric_time__day + DATEADD(day, -2, subq_22.metric_time__day) = subq_21.metric_time__day ) subq_24 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' ) subq_25 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index 9b7c4b2bef..d7fa9437b4 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -133,8 +133,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index bfd3b8fbce..3b3ab93020 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -14,10 +14,17 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__month', 'metric_time__day'] SELECT - subq_13.ds AS metric_time__day - , DATE_TRUNC('month', subq_13.ds) AS metric_time__month + subq_12.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_12.metric_time__day) AS metric_time__month , subq_11.bookings AS bookings - FROM ***************************.mf_time_spine subq_13 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_13 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -27,8 +34,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_11 ON - DATE_TRUNC('month', subq_13.ds) = subq_11.metric_time__day - WHERE DATE_TRUNC('month', subq_13.ds) = subq_13.ds + DATE_TRUNC('month', subq_12.metric_time__day) = subq_11.metric_time__day + WHERE DATE_TRUNC('month', subq_12.metric_time__day) = subq_12.metric_time__day ) subq_15 WHERE metric_time__day = '2020-01-01' GROUP BY diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_multiple_granularities__plan0.sql index cdd2a747bd..5053df40cf 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_multiple_granularities__plan0.sql @@ -129,8 +129,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql index 76767e46c6..e8bea713fe 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql @@ -10,11 +10,18 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day - , DATE_TRUNC('month', subq_11.ds) AS metric_time__month - , DATE_TRUNC('year', subq_11.ds) AS metric_time__year + subq_10.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_10.metric_time__day) AS metric_time__month + , DATE_TRUNC('year', subq_10.metric_time__day) AS metric_time__year , SUM(subq_9.bookings) AS bookings_start_of_month - FROM ***************************.mf_time_spine subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -24,9 +31,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_9 ON - DATE_TRUNC('month', subq_11.ds) = subq_9.metric_time__day + DATE_TRUNC('month', subq_10.metric_time__day) = subq_9.metric_time__day GROUP BY - subq_11.ds - , DATE_TRUNC('month', subq_11.ds) - , DATE_TRUNC('year', subq_11.ds) + subq_10.metric_time__day + , DATE_TRUNC('month', subq_10.metric_time__day) + , DATE_TRUNC('year', subq_10.metric_time__day) ) subq_15 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0.sql index 4b6fd05c9b..96900ee19f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day + DATE_TRUNC('day', subq_8.ds) AS booking__ds__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql index 87a86d9826..817001782a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day + subq_21.booking__ds__day AS booking__ds__day , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS booking__ds__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.booking__ds__day + DATE_TRUNC('month', subq_21.booking__ds__day) = subq_20.booking__ds__day GROUP BY - subq_22.ds + subq_21.booking__ds__day ) subq_26 ON subq_18.booking__ds__day = subq_26.booking__ds__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index 796a8201a6..bc374b4b7f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -139,8 +139,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index da44e813f4..3d915776f9 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -20,14 +20,21 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['booking_value', 'metric_time__month', 'metric_time__day'] SELECT - subq_21.ds AS metric_time__day - , DATE_TRUNC('month', subq_21.ds) AS metric_time__month + subq_20.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_20.metric_time__day) AS metric_time__month , bookings_source_src_28000.booking_value AS booking_value - FROM ***************************.mf_time_spine subq_21 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_21 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_20 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATEADD(week, -1, subq_21.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) + DATEADD(week, -1, subq_20.metric_time__day) = DATE_TRUNC('day', bookings_source_src_28000.ds) ) subq_23 WHERE metric_time__day = '2020-01-01' GROUP BY diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_multiple_granularities__plan0.sql index 79cd48a29a..44c632b9bb 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_multiple_granularities__plan0.sql @@ -137,8 +137,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_multiple_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_multiple_granularities__plan0_optimized.sql index 58b1be36eb..bf18d991fe 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_multiple_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_metric_multiple_granularities__plan0_optimized.sql @@ -18,19 +18,26 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , DATE_TRUNC('month', subq_17.ds) AS metric_time__month - , DATE_TRUNC('year', subq_17.ds) AS metric_time__year + subq_16.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_16.metric_time__day) AS metric_time__month + , DATE_TRUNC('year', subq_16.metric_time__day) AS metric_time__year , SUM(bookings_source_src_28000.booking_value) AS booking_value - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATEADD(week, -1, subq_17.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) + DATEADD(week, -1, subq_16.metric_time__day) = DATE_TRUNC('day', bookings_source_src_28000.ds) GROUP BY - subq_17.ds - , DATE_TRUNC('month', subq_17.ds) - , DATE_TRUNC('year', subq_17.ds) + subq_16.metric_time__day + , DATE_TRUNC('month', subq_16.metric_time__day) + , DATE_TRUNC('year', subq_16.metric_time__day) ) subq_21 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_agg_time_dim__plan0.sql index 5a5d745cc6..485bc9a255 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_agg_time_dim__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day + DATE_TRUNC('day', subq_8.ds) AS booking__ds__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_agg_time_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_agg_time_dim__plan0_optimized.sql index 82e7a89339..a9c72b80f2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_agg_time_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_agg_time_dim__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day + subq_21.booking__ds__day AS booking__ds__day , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS booking__ds__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATEADD(day, -14, subq_22.ds) = subq_20.booking__ds__day + DATEADD(day, -14, subq_21.booking__ds__day) = subq_20.booking__ds__day GROUP BY - subq_22.ds + subq_21.booking__ds__day ) subq_26 ON subq_18.booking__ds__day = subq_26.booking__ds__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0.sql index d847c8018f..bd92f15efb 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0.sql @@ -121,9 +121,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 WHERE subq_3.ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0_optimized.sql index ba6c53ac37..a02bba01aa 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Redshift/test_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -13,9 +13,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + DATE_TRUNC('day', ds) ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index 306fc5aa5f..6ffc464860 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -126,9 +126,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Join Self Over Time Range @@ -234,8 +236,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql index 3c0cf770da..6c69a2b1a3 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -14,23 +14,32 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_18 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + DATE_TRUNC('day', ds) ) subq_17 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_15.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_14.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_15.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_14.metric_time__day) ) ) subq_16 ON diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql index 5290ac6df3..6a653c82ac 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index aa15f38c06..8606ce0b97 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day + DATE_TRUNC('month', subq_21.metric_time__day) = subq_20.metric_time__day GROUP BY - subq_22.ds + subq_21.metric_time__day ) subq_26 ON subq_18.metric_time__day = subq_26.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index a5aeefa790..02945ba23f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index 808ffc27a1..ec1a53ac20 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('week', subq_22.ds) AS metric_time__week + DATE_TRUNC('week', subq_21.metric_time__day) AS metric_time__week , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,10 +51,10 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day - WHERE DATE_TRUNC('week', subq_22.ds) = subq_22.ds + DATE_TRUNC('month', subq_21.metric_time__day) = subq_20.metric_time__day + WHERE DATE_TRUNC('week', subq_21.metric_time__day) = subq_21.metric_time__day GROUP BY - DATE_TRUNC('week', subq_22.ds) + DATE_TRUNC('week', subq_21.metric_time__day) ) subq_26 ON subq_18.metric_time__week = subq_26.metric_time__week diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql index 22ca211b78..36d5010d88 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0_optimized.sql index 8eb8c6cbf9..4e47754296 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATEADD(day, -14, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -14, subq_21.metric_time__day) = subq_20.metric_time__day GROUP BY - subq_22.ds + subq_21.metric_time__day ) subq_26 ON subq_18.metric_time__day = subq_26.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 0124c7102e..26fafdc439 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index 7024c46d3a..474f3c3585 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('quarter', subq_22.ds) AS metric_time__quarter + DATE_TRUNC('quarter', subq_21.metric_time__day) AS metric_time__quarter , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATEADD(day, -14, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -14, subq_21.metric_time__day) = subq_20.metric_time__day GROUP BY - DATE_TRUNC('quarter', subq_22.ds) + DATE_TRUNC('quarter', subq_21.metric_time__day) ) subq_26 ON subq_18.metric_time__quarter = subq_26.metric_time__quarter diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 45404aae17..94103777e6 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -127,8 +127,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' @@ -452,8 +454,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day + DATE_TRUNC('day', subq_11.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', subq_11.ds) ) subq_10 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 3e62b59a02..bdab587453 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -14,9 +14,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_20.ds AS metric_time__day + subq_19.metric_time__day AS metric_time__day , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_19 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -26,9 +33,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_18 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day + DATE_TRUNC('month', subq_19.metric_time__day) = subq_18.metric_time__day GROUP BY - subq_20.ds + subq_19.metric_time__day ) subq_24 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -36,9 +43,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day + subq_27.metric_time__day AS metric_time__day , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_28 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -48,9 +62,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_26 ON - DATEADD(month, -1, subq_28.ds) = subq_26.metric_time__day + DATEADD(month, -1, subq_27.metric_time__day) = subq_26.metric_time__day GROUP BY - subq_28.ds + subq_27.metric_time__day ) subq_32 ON subq_24.metric_time__day = subq_32.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index d025b10978..2c2801cf7e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -127,8 +127,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' @@ -453,8 +455,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day + DATE_TRUNC('day', subq_11.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', subq_11.ds) ) subq_10 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index a0e28f6a63..90472faa51 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -14,9 +14,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_20.ds) AS metric_time__year + DATE_TRUNC('year', subq_19.metric_time__day) AS metric_time__year , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_19 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -26,10 +33,10 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_18 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day - WHERE DATE_TRUNC('year', subq_20.ds) = subq_20.ds + DATE_TRUNC('month', subq_19.metric_time__day) = subq_18.metric_time__day + WHERE DATE_TRUNC('year', subq_19.metric_time__day) = subq_19.metric_time__day GROUP BY - DATE_TRUNC('year', subq_20.ds) + DATE_TRUNC('year', subq_19.metric_time__day) ) subq_24 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -37,9 +44,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_28.ds) AS metric_time__year + DATE_TRUNC('year', subq_27.metric_time__day) AS metric_time__year , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_28 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -49,9 +63,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_26 ON - DATEADD(month, -1, subq_28.ds) = subq_26.metric_time__day + DATEADD(month, -1, subq_27.metric_time__day) = subq_26.metric_time__day GROUP BY - DATE_TRUNC('year', subq_28.ds) + DATE_TRUNC('year', subq_27.metric_time__day) ) subq_32 ON subq_24.metric_time__year = subq_32.metric_time__year diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 47ad965ef1..8c7c9d4a71 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -354,8 +354,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day + DATE_TRUNC('day', subq_9.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_9 + GROUP BY + DATE_TRUNC('day', subq_9.ds) ) subq_8 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql index 6e1e08a67e..f84cddd850 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql @@ -39,9 +39,16 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_25.ds AS metric_time__day + subq_24.metric_time__day AS metric_time__day , subq_23.bookings AS bookings - FROM ***************************.mf_time_spine subq_25 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_25 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -51,7 +58,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_23 ON - DATEADD(day, -14, subq_25.ds) = subq_23.metric_time__day + DATEADD(day, -14, subq_24.metric_time__day) = subq_23.metric_time__day ) subq_27 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0.sql index 6945e41530..d6e3855ec4 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0.sql @@ -121,8 +121,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Join Self Over Time Range @@ -228,8 +230,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0_optimized.sql index 8be396c4a4..6c11a5e462 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -8,26 +8,40 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day + subq_16.metric_time__day AS metric_time__day , COUNT(DISTINCT subq_15.bookers) AS every_2_days_bookers_2_days_ago - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_14.ds AS metric_time__day + subq_13.metric_time__day AS metric_time__day , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_14 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_13 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_14.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_13.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_14.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_13.metric_time__day) ) ) subq_15 ON - DATEADD(day, -2, subq_17.ds) = subq_15.metric_time__day + DATEADD(day, -2, subq_16.metric_time__day) = subq_15.metric_time__day GROUP BY - subq_17.ds + subq_16.metric_time__day ) subq_21 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0.sql index 9437092dd4..d48a264bdc 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -127,8 +127,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS booking__ds__day + DATE_TRUNC('day', subq_3.ds) AS booking__ds__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql index 1a7e109f05..5b51521c01 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql @@ -14,15 +14,22 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS booking__ds__day + subq_16.booking__ds__day AS booking__ds__day , SUM(bookings_source_src_28000.booking_value) AS booking_value - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATEADD(week, -1, subq_17.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) + DATEADD(week, -1, subq_16.booking__ds__day) = DATE_TRUNC('day', bookings_source_src_28000.ds) GROUP BY - subq_17.ds + subq_16.booking__ds__day ) subq_21 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0.sql index 3005816b74..f2b3ded65e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -121,8 +121,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index 60bbd4728c..43450c782d 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -8,9 +8,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day + subq_10.metric_time__day AS metric_time__day , SUM(subq_9.bookings) AS bookings_5_days_ago - FROM ***************************.mf_time_spine subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -20,7 +27,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_9 ON - DATEADD(day, -5, subq_11.ds) = subq_9.metric_time__day + DATEADD(day, -5, subq_10.metric_time__day) = subq_9.metric_time__day GROUP BY - subq_11.ds + subq_10.metric_time__day ) subq_15 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index 43aff53008..7597288570 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -22,8 +22,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -153,8 +155,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index f53018153d..d075578367 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -11,10 +11,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_24.ds AS metric_time__day + subq_23.metric_time__day AS metric_time__day , subq_22.booking__is_instant AS booking__is_instant , subq_22.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_24 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_24 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_23 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -27,10 +34,17 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day + subq_16.metric_time__day AS metric_time__day , subq_15.booking__is_instant AS booking__is_instant , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -41,14 +55,14 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_15 ON - DATEADD(day, -5, subq_17.ds) = subq_15.metric_time__day + DATEADD(day, -5, subq_16.metric_time__day) = subq_15.metric_time__day GROUP BY - subq_17.ds + subq_16.metric_time__day , subq_15.booking__is_instant ) subq_21 ) subq_22 ON - DATEADD(day, -2, subq_24.ds) = subq_22.metric_time__day + DATEADD(day, -2, subq_23.metric_time__day) = subq_22.metric_time__day ) subq_25 WHERE booking__is_instant ) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql index 767ed7c015..f9d74134f1 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql @@ -16,8 +16,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day + DATE_TRUNC('day', subq_7.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_7 + GROUP BY + DATE_TRUNC('day', subq_7.ds) ) subq_6 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql index b10c0ed06c..9683308f28 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql @@ -11,9 +11,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day + subq_22.metric_time__day AS metric_time__day , subq_21.booking_fees_start_of_month AS booking_fees_start_of_month - FROM ***************************.mf_time_spine subq_23 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_23 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_22 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -34,7 +41,7 @@ FROM ( ) subq_20 ) subq_21 ON - DATE_TRUNC('month', subq_23.ds) = subq_21.metric_time__day + DATE_TRUNC('month', subq_22.metric_time__day) = subq_21.metric_time__day ) subq_24 FULL OUTER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets__plan0.sql index 116816a3e2..04b79094a1 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -137,8 +139,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets__plan0_optimized.sql index d392a13fcc..5fe4ebcf07 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets__plan0_optimized.sql @@ -5,9 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , subq_20.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -19,9 +26,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -31,11 +45,11 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_13 ON - DATEADD(day, -5, subq_15.ds) = subq_13.metric_time__day + DATEADD(day, -5, subq_14.metric_time__day) = subq_13.metric_time__day GROUP BY - subq_15.ds + subq_14.metric_time__day ) subq_19 ) subq_20 ON - DATEADD(day, -2, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -2, subq_21.metric_time__day) = subq_20.metric_time__day ) subq_23 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0.sql index c1169c26fb..00bee80961 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0.sql @@ -10,9 +10,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 WHERE subq_10.ds BETWEEN '2020-01-12' AND '2020-01-13' + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -138,8 +140,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0_optimized.sql index 5ce260e750..56e779cde6 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -10,9 +10,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_22 WHERE ds BETWEEN '2020-01-12' AND '2020-01-13' + GROUP BY + DATE_TRUNC('day', ds) ) subq_21 INNER JOIN ( -- Compute Metrics via Expressions @@ -25,9 +27,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -37,9 +46,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_13 ON - DATEADD(day, -5, subq_15.ds) = subq_13.metric_time__day + DATEADD(day, -5, subq_14.metric_time__day) = subq_13.metric_time__day GROUP BY - subq_15.ds + subq_14.metric_time__day ) subq_19 ) subq_20 ON diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0.sql index 9b11a266f0..256545fab7 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0.sql @@ -15,8 +15,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -142,8 +144,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0_optimized.sql index 76818b62f5..46537d5f65 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -10,9 +10,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day + subq_22.metric_time__day AS metric_time__day , subq_21.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_23 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_23 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_22 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,9 +31,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.ds AS metric_time__day + subq_15.metric_time__day AS metric_time__day , SUM(subq_14.bookings) AS bookings - FROM ***************************.mf_time_spine subq_16 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_15 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -36,13 +50,13 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_14 ON - DATEADD(day, -5, subq_16.ds) = subq_14.metric_time__day + DATEADD(day, -5, subq_15.metric_time__day) = subq_14.metric_time__day GROUP BY - subq_16.ds + subq_15.metric_time__day ) subq_20 ) subq_21 ON - DATEADD(day, -2, subq_23.ds) = subq_21.metric_time__day + DATEADD(day, -2, subq_22.metric_time__day) = subq_21.metric_time__day ) subq_24 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' ) subq_25 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index 24810fdc57..99f8a57e5c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -133,8 +133,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index bfd3b8fbce..3b3ab93020 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -14,10 +14,17 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__month', 'metric_time__day'] SELECT - subq_13.ds AS metric_time__day - , DATE_TRUNC('month', subq_13.ds) AS metric_time__month + subq_12.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_12.metric_time__day) AS metric_time__month , subq_11.bookings AS bookings - FROM ***************************.mf_time_spine subq_13 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_13 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -27,8 +34,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_11 ON - DATE_TRUNC('month', subq_13.ds) = subq_11.metric_time__day - WHERE DATE_TRUNC('month', subq_13.ds) = subq_13.ds + DATE_TRUNC('month', subq_12.metric_time__day) = subq_11.metric_time__day + WHERE DATE_TRUNC('month', subq_12.metric_time__day) = subq_12.metric_time__day ) subq_15 WHERE metric_time__day = '2020-01-01' GROUP BY diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_multiple_granularities__plan0.sql index 9ba2ba9c0a..b20e352d2c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_multiple_granularities__plan0.sql @@ -129,8 +129,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql index 76767e46c6..e8bea713fe 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql @@ -10,11 +10,18 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day - , DATE_TRUNC('month', subq_11.ds) AS metric_time__month - , DATE_TRUNC('year', subq_11.ds) AS metric_time__year + subq_10.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_10.metric_time__day) AS metric_time__month + , DATE_TRUNC('year', subq_10.metric_time__day) AS metric_time__year , SUM(subq_9.bookings) AS bookings_start_of_month - FROM ***************************.mf_time_spine subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -24,9 +31,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_9 ON - DATE_TRUNC('month', subq_11.ds) = subq_9.metric_time__day + DATE_TRUNC('month', subq_10.metric_time__day) = subq_9.metric_time__day GROUP BY - subq_11.ds - , DATE_TRUNC('month', subq_11.ds) - , DATE_TRUNC('year', subq_11.ds) + subq_10.metric_time__day + , DATE_TRUNC('month', subq_10.metric_time__day) + , DATE_TRUNC('year', subq_10.metric_time__day) ) subq_15 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0.sql index 179b098943..50bf4d8208 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day + DATE_TRUNC('day', subq_8.ds) AS booking__ds__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql index 87a86d9826..817001782a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day + subq_21.booking__ds__day AS booking__ds__day , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS booking__ds__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.booking__ds__day + DATE_TRUNC('month', subq_21.booking__ds__day) = subq_20.booking__ds__day GROUP BY - subq_22.ds + subq_21.booking__ds__day ) subq_26 ON subq_18.booking__ds__day = subq_26.booking__ds__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index 09bf3b33db..649f63fc80 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -139,8 +139,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index da44e813f4..3d915776f9 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -20,14 +20,21 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['booking_value', 'metric_time__month', 'metric_time__day'] SELECT - subq_21.ds AS metric_time__day - , DATE_TRUNC('month', subq_21.ds) AS metric_time__month + subq_20.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_20.metric_time__day) AS metric_time__month , bookings_source_src_28000.booking_value AS booking_value - FROM ***************************.mf_time_spine subq_21 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_21 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_20 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATEADD(week, -1, subq_21.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) + DATEADD(week, -1, subq_20.metric_time__day) = DATE_TRUNC('day', bookings_source_src_28000.ds) ) subq_23 WHERE metric_time__day = '2020-01-01' GROUP BY diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_multiple_granularities__plan0.sql index 041daf1029..bceba415d3 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_multiple_granularities__plan0.sql @@ -137,8 +137,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_multiple_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_multiple_granularities__plan0_optimized.sql index 58b1be36eb..bf18d991fe 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_multiple_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_metric_multiple_granularities__plan0_optimized.sql @@ -18,19 +18,26 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , DATE_TRUNC('month', subq_17.ds) AS metric_time__month - , DATE_TRUNC('year', subq_17.ds) AS metric_time__year + subq_16.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_16.metric_time__day) AS metric_time__month + , DATE_TRUNC('year', subq_16.metric_time__day) AS metric_time__year , SUM(bookings_source_src_28000.booking_value) AS booking_value - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATEADD(week, -1, subq_17.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) + DATEADD(week, -1, subq_16.metric_time__day) = DATE_TRUNC('day', bookings_source_src_28000.ds) GROUP BY - subq_17.ds - , DATE_TRUNC('month', subq_17.ds) - , DATE_TRUNC('year', subq_17.ds) + subq_16.metric_time__day + , DATE_TRUNC('month', subq_16.metric_time__day) + , DATE_TRUNC('year', subq_16.metric_time__day) ) subq_21 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0.sql index 896d161dff..9c07a53fd2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day + DATE_TRUNC('day', subq_8.ds) AS booking__ds__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0_optimized.sql index 82e7a89339..a9c72b80f2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_agg_time_dim__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day + subq_21.booking__ds__day AS booking__ds__day , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS booking__ds__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATEADD(day, -14, subq_22.ds) = subq_20.booking__ds__day + DATEADD(day, -14, subq_21.booking__ds__day) = subq_20.booking__ds__day GROUP BY - subq_22.ds + subq_21.booking__ds__day ) subq_26 ON subq_18.booking__ds__day = subq_26.booking__ds__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0.sql index a1a6c46c56..f443c55f25 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0.sql @@ -121,9 +121,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 WHERE subq_3.ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0_optimized.sql index ba6c53ac37..a02bba01aa 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Snowflake/test_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -13,9 +13,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 WHERE ds BETWEEN '2019-12-19' AND '2020-01-02' + GROUP BY + DATE_TRUNC('day', ds) ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index ff9b7c69df..edf756e458 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -126,9 +126,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN timestamp '2019-12-19' AND timestamp '2020-01-02' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Join Self Over Time Range @@ -234,8 +236,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql index 1a9dc9da62..97f41040b7 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_cumulative_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -14,23 +14,32 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_18 WHERE ds BETWEEN timestamp '2019-12-19' AND timestamp '2020-01-02' + GROUP BY + DATE_TRUNC('day', ds) ) subq_17 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_15.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_14.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATE_ADD('day', -2, subq_15.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATE_ADD('day', -2, subq_14.metric_time__day) ) ) subq_16 ON diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain__plan0.sql index 2e3eaf8475..3bf8a8d627 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index aa15f38c06..8606ce0b97 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day + DATE_TRUNC('month', subq_21.metric_time__day) = subq_20.metric_time__day GROUP BY - subq_22.ds + subq_21.metric_time__day ) subq_26 ON subq_18.metric_time__day = subq_26.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index 25b6c37530..21ec62931e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index 808ffc27a1..ec1a53ac20 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('week', subq_22.ds) AS metric_time__week + DATE_TRUNC('week', subq_21.metric_time__day) AS metric_time__week , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,10 +51,10 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.metric_time__day - WHERE DATE_TRUNC('week', subq_22.ds) = subq_22.ds + DATE_TRUNC('month', subq_21.metric_time__day) = subq_20.metric_time__day + WHERE DATE_TRUNC('week', subq_21.metric_time__day) = subq_21.metric_time__day GROUP BY - DATE_TRUNC('week', subq_22.ds) + DATE_TRUNC('week', subq_21.metric_time__day) ) subq_26 ON subq_18.metric_time__week = subq_26.metric_time__week diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0.sql index 219b53a81e..31652d3b30 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0_optimized.sql index 2b4d820076..fa4066c560 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_ADD('day', -14, subq_22.ds) = subq_20.metric_time__day + DATE_ADD('day', -14, subq_21.metric_time__day) = subq_20.metric_time__day GROUP BY - subq_22.ds + subq_21.metric_time__day ) subq_26 ON subq_18.metric_time__day = subq_26.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 7a7f0cef1f..4e69909695 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index bffa9809e6..2fae4e6edc 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('quarter', subq_22.ds) AS metric_time__quarter + DATE_TRUNC('quarter', subq_21.metric_time__day) AS metric_time__quarter , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_ADD('day', -14, subq_22.ds) = subq_20.metric_time__day + DATE_ADD('day', -14, subq_21.metric_time__day) = subq_20.metric_time__day GROUP BY - DATE_TRUNC('quarter', subq_22.ds) + DATE_TRUNC('quarter', subq_21.metric_time__day) ) subq_26 ON subq_18.metric_time__quarter = subq_26.metric_time__quarter diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index ff70de61e8..0b4366fd23 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -127,8 +127,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' @@ -452,8 +454,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day + DATE_TRUNC('day', subq_11.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', subq_11.ds) ) subq_10 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index c7136d5198..938639ec62 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -14,9 +14,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_20.ds AS metric_time__day + subq_19.metric_time__day AS metric_time__day , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_19 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -26,9 +33,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_18 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day + DATE_TRUNC('month', subq_19.metric_time__day) = subq_18.metric_time__day GROUP BY - subq_20.ds + subq_19.metric_time__day ) subq_24 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -36,9 +43,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day + subq_27.metric_time__day AS metric_time__day , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_28 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -48,9 +62,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_26 ON - DATE_ADD('month', -1, subq_28.ds) = subq_26.metric_time__day + DATE_ADD('month', -1, subq_27.metric_time__day) = subq_26.metric_time__day GROUP BY - subq_28.ds + subq_27.metric_time__day ) subq_32 ON subq_24.metric_time__day = subq_32.metric_time__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index 9f5f5a9b1e..55aac1054d 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -127,8 +127,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' @@ -453,8 +455,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day + DATE_TRUNC('day', subq_11.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', subq_11.ds) ) subq_10 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 86c6206458..137368232a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -14,9 +14,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_20.ds) AS metric_time__year + DATE_TRUNC('year', subq_19.metric_time__day) AS metric_time__year , SUM(subq_18.bookings) AS month_start_bookings - FROM ***************************.mf_time_spine subq_20 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_20 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_19 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -26,10 +33,10 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_18 ON - DATE_TRUNC('month', subq_20.ds) = subq_18.metric_time__day - WHERE DATE_TRUNC('year', subq_20.ds) = subq_20.ds + DATE_TRUNC('month', subq_19.metric_time__day) = subq_18.metric_time__day + WHERE DATE_TRUNC('year', subq_19.metric_time__day) = subq_19.metric_time__day GROUP BY - DATE_TRUNC('year', subq_20.ds) + DATE_TRUNC('year', subq_19.metric_time__day) ) subq_24 FULL OUTER JOIN ( -- Join to Time Spine Dataset @@ -37,9 +44,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - DATE_TRUNC('year', subq_28.ds) AS metric_time__year + DATE_TRUNC('year', subq_27.metric_time__day) AS metric_time__year , SUM(subq_26.bookings) AS bookings_1_month_ago - FROM ***************************.mf_time_spine subq_28 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_28 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -49,9 +63,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_26 ON - DATE_ADD('month', -1, subq_28.ds) = subq_26.metric_time__day + DATE_ADD('month', -1, subq_27.metric_time__day) = subq_26.metric_time__day GROUP BY - DATE_TRUNC('year', subq_28.ds) + DATE_TRUNC('year', subq_27.metric_time__day) ) subq_32 ON subq_24.metric_time__year = subq_32.metric_time__year diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 6cbd2d5ff1..ac90441d6c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -354,8 +354,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_9.ds AS metric_time__day + DATE_TRUNC('day', subq_9.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_9 + GROUP BY + DATE_TRUNC('day', subq_9.ds) ) subq_8 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql index 9cf94d7fbc..fb0da7c815 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_metric_with_offset_window_and_time_filter__plan0_optimized.sql @@ -39,9 +39,16 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__day'] SELECT - subq_25.ds AS metric_time__day + subq_24.metric_time__day AS metric_time__day , subq_23.bookings AS bookings - FROM ***************************.mf_time_spine subq_25 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_25 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_24 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -51,7 +58,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_23 ON - DATE_ADD('day', -14, subq_25.ds) = subq_23.metric_time__day + DATE_ADD('day', -14, subq_24.metric_time__day) = subq_23.metric_time__day ) subq_27 WHERE metric_time__day = '2020-01-01' or metric_time__day = '2020-01-14' GROUP BY diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0.sql index 5e647c5106..ae1607b835 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0.sql @@ -121,8 +121,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 INNER JOIN ( -- Join Self Over Time Range @@ -228,8 +230,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0_optimized.sql index f840ae4582..29ff7123da 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -8,26 +8,40 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day + subq_16.metric_time__day AS metric_time__day , COUNT(DISTINCT subq_15.bookers) AS every_2_days_bookers_2_days_ago - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ( -- Join Self Over Time Range SELECT - subq_14.ds AS metric_time__day + subq_13.metric_time__day AS metric_time__day , bookings_source_src_28000.guest_id AS bookers - FROM ***************************.mf_time_spine subq_14 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_14 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_13 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_14.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_13.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATE_ADD('day', -2, subq_14.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATE_ADD('day', -2, subq_13.metric_time__day) ) ) subq_15 ON - DATE_ADD('day', -2, subq_17.ds) = subq_15.metric_time__day + DATE_ADD('day', -2, subq_16.metric_time__day) = subq_15.metric_time__day GROUP BY - subq_17.ds + subq_16.metric_time__day ) subq_21 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0.sql index fe961785b5..074e4f4d1a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -127,8 +127,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS booking__ds__day + DATE_TRUNC('day', subq_3.ds) AS booking__ds__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql index f0f24eca1c..bbe5c453a0 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_agg_time_dim__plan0_optimized.sql @@ -14,15 +14,22 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS booking__ds__day + subq_16.booking__ds__day AS booking__ds__day , SUM(bookings_source_src_28000.booking_value) AS booking_value - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS booking__ds__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATE_ADD('week', -1, subq_17.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) + DATE_ADD('week', -1, subq_16.booking__ds__day) = DATE_TRUNC('day', bookings_source_src_28000.ds) GROUP BY - subq_17.ds + subq_16.booking__ds__day ) subq_21 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0.sql index 385bcc0ba0..0c7fdae516 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -121,8 +121,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index 57c8a47d84..49f1a0f2d5 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -8,9 +8,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day + subq_10.metric_time__day AS metric_time__day , SUM(subq_9.bookings) AS bookings_5_days_ago - FROM ***************************.mf_time_spine subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -20,7 +27,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_9 ON - DATE_ADD('day', -5, subq_11.ds) = subq_9.metric_time__day + DATE_ADD('day', -5, subq_10.metric_time__day) = subq_9.metric_time__day GROUP BY - subq_11.ds + subq_10.metric_time__day ) subq_15 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index 080be3077a..3c78ba5249 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -22,8 +22,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -153,8 +155,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql index ce5a3209e3..b1a4c3f6af 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0_optimized.sql @@ -11,10 +11,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_24.ds AS metric_time__day + subq_23.metric_time__day AS metric_time__day , subq_22.booking__is_instant AS booking__is_instant , subq_22.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_24 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_24 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_23 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -27,10 +34,17 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day + subq_16.metric_time__day AS metric_time__day , subq_15.booking__is_instant AS booking__is_instant , SUM(subq_15.bookings) AS bookings - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -41,14 +55,14 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_15 ON - DATE_ADD('day', -5, subq_17.ds) = subq_15.metric_time__day + DATE_ADD('day', -5, subq_16.metric_time__day) = subq_15.metric_time__day GROUP BY - subq_17.ds + subq_16.metric_time__day , subq_15.booking__is_instant ) subq_21 ) subq_22 ON - DATE_ADD('day', -2, subq_24.ds) = subq_22.metric_time__day + DATE_ADD('day', -2, subq_23.metric_time__day) = subq_22.metric_time__day ) subq_25 WHERE booking__is_instant ) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql index 93ca864b6c..4e81ef5eb5 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0.sql @@ -16,8 +16,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day + DATE_TRUNC('day', subq_7.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_7 + GROUP BY + DATE_TRUNC('day', subq_7.ds) ) subq_6 INNER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql index b10c0ed06c..9683308f28 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_derived_metric_with_offset_multiple_input_metrics__plan0_optimized.sql @@ -11,9 +11,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day + subq_22.metric_time__day AS metric_time__day , subq_21.booking_fees_start_of_month AS booking_fees_start_of_month - FROM ***************************.mf_time_spine subq_23 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_23 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_22 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -34,7 +41,7 @@ FROM ( ) subq_20 ) subq_21 ON - DATE_TRUNC('month', subq_23.ds) = subq_21.metric_time__day + DATE_TRUNC('month', subq_22.metric_time__day) = subq_21.metric_time__day ) subq_24 FULL OUTER JOIN ( -- Compute Metrics via Expressions diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets__plan0.sql index 44af827d27..021c1c45cb 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -137,8 +139,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets__plan0_optimized.sql index 83038dfd25..a8be1a4b57 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets__plan0_optimized.sql @@ -5,9 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , subq_20.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -19,9 +26,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -31,11 +45,11 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_13 ON - DATE_ADD('day', -5, subq_15.ds) = subq_13.metric_time__day + DATE_ADD('day', -5, subq_14.metric_time__day) = subq_13.metric_time__day GROUP BY - subq_15.ds + subq_14.metric_time__day ) subq_19 ) subq_20 ON - DATE_ADD('day', -2, subq_22.ds) = subq_20.metric_time__day + DATE_ADD('day', -2, subq_21.metric_time__day) = subq_20.metric_time__day ) subq_23 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_time_constraint__plan0.sql index 7f06fe45be..d403ea9839 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_time_constraint__plan0.sql @@ -10,9 +10,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 WHERE subq_10.ds BETWEEN timestamp '2020-01-12' AND timestamp '2020-01-13' + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -138,8 +140,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_time_constraint__plan0_optimized.sql index 103e42fb2e..2db89fbdbe 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_time_constraint__plan0_optimized.sql @@ -10,9 +10,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_22 WHERE ds BETWEEN timestamp '2020-01-12' AND timestamp '2020-01-13' + GROUP BY + DATE_TRUNC('day', ds) ) subq_21 INNER JOIN ( -- Compute Metrics via Expressions @@ -25,9 +27,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , SUM(subq_13.bookings) AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -37,9 +46,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_13 ON - DATE_ADD('day', -5, subq_15.ds) = subq_13.metric_time__day + DATE_ADD('day', -5, subq_14.metric_time__day) = subq_13.metric_time__day GROUP BY - subq_15.ds + subq_14.metric_time__day ) subq_19 ) subq_20 ON diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_where_constraint__plan0.sql index 6245df2b52..7238231a0b 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_where_constraint__plan0.sql @@ -15,8 +15,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_10.ds AS metric_time__day + DATE_TRUNC('day', subq_10.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_10 + GROUP BY + DATE_TRUNC('day', subq_10.ds) ) subq_9 INNER JOIN ( -- Compute Metrics via Expressions @@ -142,8 +144,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_where_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_where_constraint__plan0_optimized.sql index 610dfdee20..3d8237c6fc 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_where_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_nested_offsets_with_where_constraint__plan0_optimized.sql @@ -10,9 +10,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_23.ds AS metric_time__day + subq_22.metric_time__day AS metric_time__day , subq_21.bookings_offset_once AS bookings_offset_once - FROM ***************************.mf_time_spine subq_23 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_23 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_22 INNER JOIN ( -- Compute Metrics via Expressions SELECT @@ -24,9 +31,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_16.ds AS metric_time__day + subq_15.metric_time__day AS metric_time__day , SUM(subq_14.bookings) AS bookings - FROM ***************************.mf_time_spine subq_16 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_15 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -36,13 +50,13 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_14 ON - DATE_ADD('day', -5, subq_16.ds) = subq_14.metric_time__day + DATE_ADD('day', -5, subq_15.metric_time__day) = subq_14.metric_time__day GROUP BY - subq_16.ds + subq_15.metric_time__day ) subq_20 ) subq_21 ON - DATE_ADD('day', -2, subq_23.ds) = subq_21.metric_time__day + DATE_ADD('day', -2, subq_22.metric_time__day) = subq_21.metric_time__day ) subq_24 WHERE metric_time__day = '2020-01-12' or metric_time__day = '2020-01-13' ) subq_25 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index 26bb799b98..5346d84697 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -133,8 +133,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index bfd3b8fbce..3b3ab93020 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -14,10 +14,17 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'metric_time__month', 'metric_time__day'] SELECT - subq_13.ds AS metric_time__day - , DATE_TRUNC('month', subq_13.ds) AS metric_time__month + subq_12.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_12.metric_time__day) AS metric_time__month , subq_11.bookings AS bookings - FROM ***************************.mf_time_spine subq_13 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_13 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_12 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -27,8 +34,8 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_11 ON - DATE_TRUNC('month', subq_13.ds) = subq_11.metric_time__day - WHERE DATE_TRUNC('month', subq_13.ds) = subq_13.ds + DATE_TRUNC('month', subq_12.metric_time__day) = subq_11.metric_time__day + WHERE DATE_TRUNC('month', subq_12.metric_time__day) = subq_12.metric_time__day ) subq_15 WHERE metric_time__day = '2020-01-01' GROUP BY diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_multiple_granularities__plan0.sql index 3491cd1852..3e55cc9f8d 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_multiple_granularities__plan0.sql @@ -129,8 +129,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql index 76767e46c6..e8bea713fe 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql @@ -10,11 +10,18 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day - , DATE_TRUNC('month', subq_11.ds) AS metric_time__month - , DATE_TRUNC('year', subq_11.ds) AS metric_time__year + subq_10.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_10.metric_time__day) AS metric_time__month + , DATE_TRUNC('year', subq_10.metric_time__day) AS metric_time__year , SUM(subq_9.bookings) AS bookings_start_of_month - FROM ***************************.mf_time_spine subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -24,9 +31,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_9 ON - DATE_TRUNC('month', subq_11.ds) = subq_9.metric_time__day + DATE_TRUNC('month', subq_10.metric_time__day) = subq_9.metric_time__day GROUP BY - subq_11.ds - , DATE_TRUNC('month', subq_11.ds) - , DATE_TRUNC('year', subq_11.ds) + subq_10.metric_time__day + , DATE_TRUNC('month', subq_10.metric_time__day) + , DATE_TRUNC('year', subq_10.metric_time__day) ) subq_15 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0.sql index 29c0d4d062..4b9ffb8ed9 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day + DATE_TRUNC('day', subq_8.ds) AS booking__ds__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql index 87a86d9826..817001782a 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_to_grain_with_agg_time_dim__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day + subq_21.booking__ds__day AS booking__ds__day , SUM(subq_20.bookings) AS bookings_at_start_of_month - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS booking__ds__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_TRUNC('month', subq_22.ds) = subq_20.booking__ds__day + DATE_TRUNC('month', subq_21.booking__ds__day) = subq_20.booking__ds__day GROUP BY - subq_22.ds + subq_21.booking__ds__day ) subq_26 ON subq_18.booking__ds__day = subq_26.booking__ds__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index 119f12fed2..0928606507 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -139,8 +139,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index 5b548d42a9..a45eb746b9 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -20,14 +20,21 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['booking_value', 'metric_time__month', 'metric_time__day'] SELECT - subq_21.ds AS metric_time__day - , DATE_TRUNC('month', subq_21.ds) AS metric_time__month + subq_20.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_20.metric_time__day) AS metric_time__month , bookings_source_src_28000.booking_value AS booking_value - FROM ***************************.mf_time_spine subq_21 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_21 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_20 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATE_ADD('week', -1, subq_21.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) + DATE_ADD('week', -1, subq_20.metric_time__day) = DATE_TRUNC('day', bookings_source_src_28000.ds) ) subq_23 WHERE metric_time__day = '2020-01-01' GROUP BY diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_multiple_granularities__plan0.sql index 1dc6e47519..8ab5b0e618 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_multiple_granularities__plan0.sql @@ -137,8 +137,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_multiple_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_multiple_granularities__plan0_optimized.sql index 183eb8a765..0823974f57 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_multiple_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_metric_multiple_granularities__plan0_optimized.sql @@ -18,19 +18,26 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , DATE_TRUNC('month', subq_17.ds) AS metric_time__month - , DATE_TRUNC('year', subq_17.ds) AS metric_time__year + subq_16.metric_time__day AS metric_time__day + , DATE_TRUNC('month', subq_16.metric_time__day) AS metric_time__month + , DATE_TRUNC('year', subq_16.metric_time__day) AS metric_time__year , SUM(bookings_source_src_28000.booking_value) AS booking_value - FROM ***************************.mf_time_spine subq_17 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_17 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_16 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON - DATE_ADD('week', -1, subq_17.ds) = DATE_TRUNC('day', bookings_source_src_28000.ds) + DATE_ADD('week', -1, subq_16.metric_time__day) = DATE_TRUNC('day', bookings_source_src_28000.ds) GROUP BY - subq_17.ds - , DATE_TRUNC('month', subq_17.ds) - , DATE_TRUNC('year', subq_17.ds) + subq_16.metric_time__day + , DATE_TRUNC('month', subq_16.metric_time__day) + , DATE_TRUNC('year', subq_16.metric_time__day) ) subq_21 FULL OUTER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_agg_time_dim__plan0.sql index acfa5e5aeb..c8130ca065 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_agg_time_dim__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS booking__ds__day + DATE_TRUNC('day', subq_8.ds) AS booking__ds__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_agg_time_dim__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_agg_time_dim__plan0_optimized.sql index 3b8fc2c3cc..5a2539031c 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_agg_time_dim__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_agg_time_dim__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_22.ds AS booking__ds__day + subq_21.booking__ds__day AS booking__ds__day , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS booking__ds__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_ADD('day', -14, subq_22.ds) = subq_20.booking__ds__day + DATE_ADD('day', -14, subq_21.booking__ds__day) = subq_20.booking__ds__day GROUP BY - subq_22.ds + subq_21.booking__ds__day ) subq_26 ON subq_18.booking__ds__day = subq_26.booking__ds__day diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_time_offset_metric_with_time_constraint__plan0.sql index a58a3aa8d4..1b00e1a9d3 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_time_offset_metric_with_time_constraint__plan0.sql @@ -121,9 +121,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 WHERE subq_3.ds BETWEEN timestamp '2019-12-19' AND timestamp '2020-01-02' + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_time_offset_metric_with_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_time_offset_metric_with_time_constraint__plan0_optimized.sql index 6d94d571a2..5fbc5f3f0f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_time_offset_metric_with_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/Trino/test_time_offset_metric_with_time_constraint__plan0_optimized.sql @@ -13,9 +13,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 WHERE ds BETWEEN timestamp '2019-12-19' AND timestamp '2020-01-02' + GROUP BY + DATE_TRUNC('day', ds) ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_fill_nulls__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_fill_nulls__plan0.sql index 8de9be463c..d43df38ebd 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_fill_nulls__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_fill_nulls__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATETIME_TRUNC(subq_8.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + metric_time__day ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures @@ -127,8 +129,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + metric_time__day ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_fill_nulls__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_fill_nulls__plan0_optimized.sql index 9f1f38bb1e..b33cafff07 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_fill_nulls__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_fill_nulls__plan0_optimized.sql @@ -5,28 +5,42 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_18.ds AS metric_time__day + subq_17.metric_time__day AS metric_time__day , subq_16.bookers AS bookers - FROM ***************************.mf_time_spine subq_18 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_18 + GROUP BY + metric_time__day + ) subq_17 LEFT OUTER JOIN ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures SELECT - subq_13.ds AS metric_time__day + subq_12.metric_time__day AS metric_time__day , COUNT(DISTINCT bookings_source_src_28000.guest_id) AS bookers - FROM ***************************.mf_time_spine subq_13 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_13 + GROUP BY + metric_time__day + ) subq_12 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATETIME_TRUNC(bookings_source_src_28000.ds, day) <= subq_13.ds + DATETIME_TRUNC(bookings_source_src_28000.ds, day) <= subq_12.metric_time__day ) AND ( - DATETIME_TRUNC(bookings_source_src_28000.ds, day) > DATE_SUB(CAST(subq_13.ds AS DATETIME), INTERVAL 2 day) + DATETIME_TRUNC(bookings_source_src_28000.ds, day) > DATE_SUB(CAST(subq_12.metric_time__day AS DATETIME), INTERVAL 2 day) ) GROUP BY metric_time__day ) subq_16 ON - subq_18.ds = subq_16.metric_time__day + subq_17.metric_time__day = subq_16.metric_time__day ) subq_19 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 984a4b8ae0..9f01478016 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -21,8 +21,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATETIME_TRUNC(subq_5.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + metric_time__day ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures @@ -356,8 +358,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day + DATETIME_TRUNC(subq_11.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_11 + GROUP BY + metric_time__day ) subq_10 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index 87d53fcbb9..b03f0617d8 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -16,9 +16,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , subq_20.bookings AS bookings - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + metric_time__day + ) subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -37,7 +44,7 @@ FROM ( metric_time__day ) subq_20 ON - subq_22.ds = subq_20.metric_time__day + subq_21.metric_time__day = subq_20.metric_time__day ) subq_23 ) subq_24 FULL OUTER JOIN ( @@ -46,9 +53,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day + subq_27.metric_time__day AS metric_time__day , SUM(subq_26.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_28 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_28 + GROUP BY + metric_time__day + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -58,7 +72,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_26 ON - DATE_SUB(CAST(subq_28.ds AS DATETIME), INTERVAL 14 day) = subq_26.metric_time__day + DATE_SUB(CAST(subq_27.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_26.metric_time__day GROUP BY metric_time__day ) subq_32 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0.sql index 67725fef7f..33480660f8 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0.sql @@ -15,9 +15,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATETIME_TRUNC(subq_8.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_8 WHERE subq_8.ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + metric_time__day ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0_optimized.sql index bc2408e75b..cf46a7ee0a 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_filters__plan0_optimized.sql @@ -11,9 +11,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATETIME_TRUNC(ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_19 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + metric_time__day ) subq_18 LEFT OUTER JOIN ( -- Constrain Output with WHERE diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_metric_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_metric_time__plan0.sql index 5812cc2483..25d9fb5757 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_metric_time__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATETIME_TRUNC(subq_5.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + metric_time__day ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql index 9d4fa355d8..d76384cee7 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/BigQuery/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql @@ -5,9 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_12.ds AS metric_time__day + subq_11.metric_time__day AS metric_time__day , subq_10.bookings AS bookings - FROM ***************************.mf_time_spine subq_12 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + GROUP BY + metric_time__day + ) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -26,5 +33,5 @@ FROM ( metric_time__day ) subq_10 ON - subq_12.ds = subq_10.metric_time__day + subq_11.metric_time__day = subq_10.metric_time__day ) subq_13 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_cumulative_fill_nulls__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_cumulative_fill_nulls__plan0.sql index b469ba34db..6d83f9c646 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_cumulative_fill_nulls__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_cumulative_fill_nulls__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures @@ -127,8 +129,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_cumulative_fill_nulls__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_cumulative_fill_nulls__plan0_optimized.sql index d32d1947ec..0860d374cd 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_cumulative_fill_nulls__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_cumulative_fill_nulls__plan0_optimized.sql @@ -5,28 +5,42 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_18.ds AS metric_time__day + subq_17.metric_time__day AS metric_time__day , subq_16.bookers AS bookers - FROM ***************************.mf_time_spine subq_18 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_17 LEFT OUTER JOIN ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures SELECT - subq_13.ds AS metric_time__day + subq_12.metric_time__day AS metric_time__day , COUNT(DISTINCT bookings_source_src_28000.guest_id) AS bookers - FROM ***************************.mf_time_spine subq_13 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_13 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_12 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_13.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_12.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_13.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_12.metric_time__day) ) GROUP BY - subq_13.ds + subq_12.metric_time__day ) subq_16 ON - subq_18.ds = subq_16.metric_time__day + subq_17.metric_time__day = subq_16.metric_time__day ) subq_19 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 1f30074712..2358c119a9 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -21,8 +21,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures @@ -356,8 +358,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day + DATE_TRUNC('day', subq_11.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', subq_11.ds) ) subq_10 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index 7aebf57d13..37f92d8070 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -16,9 +16,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , subq_20.bookings AS bookings - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -37,7 +44,7 @@ FROM ( metric_time__day ) subq_20 ON - subq_22.ds = subq_20.metric_time__day + subq_21.metric_time__day = subq_20.metric_time__day ) subq_23 ) subq_24 FULL OUTER JOIN ( @@ -46,9 +53,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day + subq_27.metric_time__day AS metric_time__day , SUM(subq_26.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_28 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_28 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -58,9 +72,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_26 ON - DATEADD(day, -14, subq_28.ds) = subq_26.metric_time__day + DATEADD(day, -14, subq_27.metric_time__day) = subq_26.metric_time__day GROUP BY - subq_28.ds + subq_27.metric_time__day ) subq_32 ON subq_24.metric_time__day = subq_32.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0.sql index 280c817e10..7cec2bbcb6 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0.sql @@ -15,9 +15,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 WHERE subq_8.ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0_optimized.sql index ae0e42a39e..9a2899f346 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_filters__plan0_optimized.sql @@ -11,9 +11,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_19 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + DATE_TRUNC('day', ds) ) subq_18 LEFT OUTER JOIN ( -- Constrain Output with WHERE diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_metric_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_metric_time__plan0.sql index 513af8589e..722c030c12 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_metric_time__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql index 591b4614fd..48714d9c84 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Databricks/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql @@ -5,9 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_12.ds AS metric_time__day + subq_11.metric_time__day AS metric_time__day , subq_10.bookings AS bookings - FROM ***************************.mf_time_spine subq_12 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -26,5 +33,5 @@ FROM ( metric_time__day ) subq_10 ON - subq_12.ds = subq_10.metric_time__day + subq_11.metric_time__day = subq_10.metric_time__day ) subq_13 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_cumulative_fill_nulls__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_cumulative_fill_nulls__plan0.sql index f6c9632e5f..7c97f35c39 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_cumulative_fill_nulls__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_cumulative_fill_nulls__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures @@ -127,8 +129,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_cumulative_fill_nulls__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_cumulative_fill_nulls__plan0_optimized.sql index 0015e66542..1ac7579f8b 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_cumulative_fill_nulls__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_cumulative_fill_nulls__plan0_optimized.sql @@ -5,28 +5,42 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_18.ds AS metric_time__day + subq_17.metric_time__day AS metric_time__day , subq_16.bookers AS bookers - FROM ***************************.mf_time_spine subq_18 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_17 LEFT OUTER JOIN ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures SELECT - subq_13.ds AS metric_time__day + subq_12.metric_time__day AS metric_time__day , COUNT(DISTINCT bookings_source_src_28000.guest_id) AS bookers - FROM ***************************.mf_time_spine subq_13 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_13 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_12 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_13.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_12.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > subq_13.ds - MAKE_INTERVAL(days => 2) + DATE_TRUNC('day', bookings_source_src_28000.ds) > subq_12.metric_time__day - MAKE_INTERVAL(days => 2) ) GROUP BY - subq_13.ds + subq_12.metric_time__day ) subq_16 ON - subq_18.ds = subq_16.metric_time__day + subq_17.metric_time__day = subq_16.metric_time__day ) subq_19 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0.sql index eab935741e..f28d28d280 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -21,8 +21,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures @@ -356,8 +358,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day + DATE_TRUNC('day', subq_11.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', subq_11.ds) ) subq_10 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index 1466014ae4..f64c29b294 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -16,9 +16,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , subq_20.bookings AS bookings - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -37,7 +44,7 @@ FROM ( metric_time__day ) subq_20 ON - subq_22.ds = subq_20.metric_time__day + subq_21.metric_time__day = subq_20.metric_time__day ) subq_23 ) subq_24 FULL OUTER JOIN ( @@ -46,9 +53,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day + subq_27.metric_time__day AS metric_time__day , SUM(subq_26.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_28 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_28 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -58,9 +72,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_26 ON - subq_28.ds - MAKE_INTERVAL(days => 14) = subq_26.metric_time__day + subq_27.metric_time__day - MAKE_INTERVAL(days => 14) = subq_26.metric_time__day GROUP BY - subq_28.ds + subq_27.metric_time__day ) subq_32 ON subq_24.metric_time__day = subq_32.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0.sql index 007e38a03c..1eb1ea3c16 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0.sql @@ -15,9 +15,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 WHERE subq_8.ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0_optimized.sql index ae0e42a39e..9a2899f346 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_filters__plan0_optimized.sql @@ -11,9 +11,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_19 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + DATE_TRUNC('day', ds) ) subq_18 LEFT OUTER JOIN ( -- Constrain Output with WHERE diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_metric_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_metric_time__plan0.sql index bd106944b5..0c4601f84c 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_metric_time__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql index 591b4614fd..48714d9c84 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Postgres/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql @@ -5,9 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_12.ds AS metric_time__day + subq_11.metric_time__day AS metric_time__day , subq_10.bookings AS bookings - FROM ***************************.mf_time_spine subq_12 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -26,5 +33,5 @@ FROM ( metric_time__day ) subq_10 ON - subq_12.ds = subq_10.metric_time__day + subq_11.metric_time__day = subq_10.metric_time__day ) subq_13 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_cumulative_fill_nulls__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_cumulative_fill_nulls__plan0.sql index 506eee1118..3ec877056d 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_cumulative_fill_nulls__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_cumulative_fill_nulls__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures @@ -127,8 +129,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_cumulative_fill_nulls__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_cumulative_fill_nulls__plan0_optimized.sql index d32d1947ec..0860d374cd 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_cumulative_fill_nulls__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_cumulative_fill_nulls__plan0_optimized.sql @@ -5,28 +5,42 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_18.ds AS metric_time__day + subq_17.metric_time__day AS metric_time__day , subq_16.bookers AS bookers - FROM ***************************.mf_time_spine subq_18 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_17 LEFT OUTER JOIN ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures SELECT - subq_13.ds AS metric_time__day + subq_12.metric_time__day AS metric_time__day , COUNT(DISTINCT bookings_source_src_28000.guest_id) AS bookers - FROM ***************************.mf_time_spine subq_13 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_13 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_12 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_13.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_12.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_13.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_12.metric_time__day) ) GROUP BY - subq_13.ds + subq_12.metric_time__day ) subq_16 ON - subq_18.ds = subq_16.metric_time__day + subq_17.metric_time__day = subq_16.metric_time__day ) subq_19 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 560ae7e845..2bfa86d635 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -21,8 +21,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures @@ -356,8 +358,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day + DATE_TRUNC('day', subq_11.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', subq_11.ds) ) subq_10 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index 7aebf57d13..37f92d8070 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -16,9 +16,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , subq_20.bookings AS bookings - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -37,7 +44,7 @@ FROM ( metric_time__day ) subq_20 ON - subq_22.ds = subq_20.metric_time__day + subq_21.metric_time__day = subq_20.metric_time__day ) subq_23 ) subq_24 FULL OUTER JOIN ( @@ -46,9 +53,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day + subq_27.metric_time__day AS metric_time__day , SUM(subq_26.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_28 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_28 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -58,9 +72,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_26 ON - DATEADD(day, -14, subq_28.ds) = subq_26.metric_time__day + DATEADD(day, -14, subq_27.metric_time__day) = subq_26.metric_time__day GROUP BY - subq_28.ds + subq_27.metric_time__day ) subq_32 ON subq_24.metric_time__day = subq_32.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0.sql index fa6e5a96cd..b51e7f495f 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0.sql @@ -15,9 +15,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 WHERE subq_8.ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0_optimized.sql index ae0e42a39e..9a2899f346 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_filters__plan0_optimized.sql @@ -11,9 +11,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_19 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + DATE_TRUNC('day', ds) ) subq_18 LEFT OUTER JOIN ( -- Constrain Output with WHERE diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_metric_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_metric_time__plan0.sql index 1d9cf76bfb..c181abffa9 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_metric_time__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql index 591b4614fd..48714d9c84 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Redshift/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql @@ -5,9 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_12.ds AS metric_time__day + subq_11.metric_time__day AS metric_time__day , subq_10.bookings AS bookings - FROM ***************************.mf_time_spine subq_12 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -26,5 +33,5 @@ FROM ( metric_time__day ) subq_10 ON - subq_12.ds = subq_10.metric_time__day + subq_11.metric_time__day = subq_10.metric_time__day ) subq_13 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_fill_nulls__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_fill_nulls__plan0.sql index c38b6b1ab5..fb63ee3510 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_fill_nulls__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_fill_nulls__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures @@ -127,8 +129,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_fill_nulls__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_fill_nulls__plan0_optimized.sql index d32d1947ec..0860d374cd 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_fill_nulls__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_fill_nulls__plan0_optimized.sql @@ -5,28 +5,42 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_18.ds AS metric_time__day + subq_17.metric_time__day AS metric_time__day , subq_16.bookers AS bookers - FROM ***************************.mf_time_spine subq_18 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_17 LEFT OUTER JOIN ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures SELECT - subq_13.ds AS metric_time__day + subq_12.metric_time__day AS metric_time__day , COUNT(DISTINCT bookings_source_src_28000.guest_id) AS bookers - FROM ***************************.mf_time_spine subq_13 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_13 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_12 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_13.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_12.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_13.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATEADD(day, -2, subq_12.metric_time__day) ) GROUP BY - subq_13.ds + subq_12.metric_time__day ) subq_16 ON - subq_18.ds = subq_16.metric_time__day + subq_17.metric_time__day = subq_16.metric_time__day ) subq_19 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 333d2eaaba..f860035eac 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -21,8 +21,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures @@ -356,8 +358,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day + DATE_TRUNC('day', subq_11.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', subq_11.ds) ) subq_10 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index 7aebf57d13..37f92d8070 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -16,9 +16,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , subq_20.bookings AS bookings - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -37,7 +44,7 @@ FROM ( metric_time__day ) subq_20 ON - subq_22.ds = subq_20.metric_time__day + subq_21.metric_time__day = subq_20.metric_time__day ) subq_23 ) subq_24 FULL OUTER JOIN ( @@ -46,9 +53,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day + subq_27.metric_time__day AS metric_time__day , SUM(subq_26.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_28 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_28 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -58,9 +72,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_26 ON - DATEADD(day, -14, subq_28.ds) = subq_26.metric_time__day + DATEADD(day, -14, subq_27.metric_time__day) = subq_26.metric_time__day GROUP BY - subq_28.ds + subq_27.metric_time__day ) subq_32 ON subq_24.metric_time__day = subq_32.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0.sql index 31df3a2c8d..b6722106a9 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0.sql @@ -15,9 +15,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 WHERE subq_8.ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0_optimized.sql index ae0e42a39e..9a2899f346 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_filters__plan0_optimized.sql @@ -11,9 +11,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_19 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + DATE_TRUNC('day', ds) ) subq_18 LEFT OUTER JOIN ( -- Constrain Output with WHERE diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_metric_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_metric_time__plan0.sql index 1e6c628c7e..9988504d5e 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_metric_time__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql index 591b4614fd..48714d9c84 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Snowflake/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql @@ -5,9 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_12.ds AS metric_time__day + subq_11.metric_time__day AS metric_time__day , subq_10.bookings AS bookings - FROM ***************************.mf_time_spine subq_12 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -26,5 +33,5 @@ FROM ( metric_time__day ) subq_10 ON - subq_12.ds = subq_10.metric_time__day + subq_11.metric_time__day = subq_10.metric_time__day ) subq_13 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_cumulative_fill_nulls__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_cumulative_fill_nulls__plan0.sql index 593f90d343..74901d41f4 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_cumulative_fill_nulls__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_cumulative_fill_nulls__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures @@ -127,8 +129,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_cumulative_fill_nulls__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_cumulative_fill_nulls__plan0_optimized.sql index 370a5e255e..db2e5d657b 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_cumulative_fill_nulls__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_cumulative_fill_nulls__plan0_optimized.sql @@ -5,28 +5,42 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_18.ds AS metric_time__day + subq_17.metric_time__day AS metric_time__day , subq_16.bookers AS bookers - FROM ***************************.mf_time_spine subq_18 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_17 LEFT OUTER JOIN ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'metric_time__day'] -- Aggregate Measures SELECT - subq_13.ds AS metric_time__day + subq_12.metric_time__day AS metric_time__day , COUNT(DISTINCT bookings_source_src_28000.guest_id) AS bookers - FROM ***************************.mf_time_spine subq_13 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_13 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_12 INNER JOIN ***************************.fct_bookings bookings_source_src_28000 ON ( - DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_13.ds + DATE_TRUNC('day', bookings_source_src_28000.ds) <= subq_12.metric_time__day ) AND ( - DATE_TRUNC('day', bookings_source_src_28000.ds) > DATE_ADD('day', -2, subq_13.ds) + DATE_TRUNC('day', bookings_source_src_28000.ds) > DATE_ADD('day', -2, subq_12.metric_time__day) ) GROUP BY - subq_13.ds + subq_12.metric_time__day ) subq_16 ON - subq_18.ds = subq_16.metric_time__day + subq_17.metric_time__day = subq_16.metric_time__day ) subq_19 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 1c645ecec6..82af9c6c2e 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -21,8 +21,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures @@ -356,8 +358,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_11.ds AS metric_time__day + DATE_TRUNC('day', subq_11.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_11 + GROUP BY + DATE_TRUNC('day', subq_11.ds) ) subq_10 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql index d5ffd5e9bd..0b0f97da53 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_derived_fill_nulls_for_one_input_metric__plan0_optimized.sql @@ -16,9 +16,16 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_22.ds AS metric_time__day + subq_21.metric_time__day AS metric_time__day , subq_20.bookings AS bookings - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -37,7 +44,7 @@ FROM ( metric_time__day ) subq_20 ON - subq_22.ds = subq_20.metric_time__day + subq_21.metric_time__day = subq_20.metric_time__day ) subq_23 ) subq_24 FULL OUTER JOIN ( @@ -46,9 +53,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_28.ds AS metric_time__day + subq_27.metric_time__day AS metric_time__day , SUM(subq_26.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_28 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_28 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_27 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -58,9 +72,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_26 ON - DATE_ADD('day', -14, subq_28.ds) = subq_26.metric_time__day + DATE_ADD('day', -14, subq_27.metric_time__day) = subq_26.metric_time__day GROUP BY - subq_28.ds + subq_27.metric_time__day ) subq_32 ON subq_24.metric_time__day = subq_32.metric_time__day diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0.sql index 886415bad4..6ca4d4f809 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0.sql @@ -15,9 +15,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 WHERE subq_8.ds BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0_optimized.sql index e2374068e9..a82b44a563 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_filters__plan0_optimized.sql @@ -11,9 +11,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_19 WHERE ds BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' + GROUP BY + DATE_TRUNC('day', ds) ) subq_18 LEFT OUTER JOIN ( -- Constrain Output with WHERE diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_metric_time__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_metric_time__plan0.sql index 8071271763..03108ec711 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_metric_time__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_metric_time__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql index 591b4614fd..48714d9c84 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/Trino/test_simple_fill_nulls_with_0_metric_time__plan0_optimized.sql @@ -5,9 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_12.ds AS metric_time__day + subq_11.metric_time__day AS metric_time__day , subq_10.bookings AS bookings - FROM ***************************.mf_time_spine subq_12 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -26,5 +33,5 @@ FROM ( metric_time__day ) subq_10 ON - subq_12.ds = subq_10.metric_time__day + subq_11.metric_time__day = subq_10.metric_time__day ) subq_13 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0.sql index 5885d993cc..849899b524 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATETIME_TRUNC(subq_8.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + metric_time__day ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0_optimized.sql index 109240c757..a0383a28e8 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - IF(EXTRACT(dayofweek FROM subq_22.ds) = 1, 7, EXTRACT(dayofweek FROM subq_22.ds) - 1) AS metric_time__extract_dow + IF(EXTRACT(dayofweek FROM subq_21.metric_time__day) = 1, 7, EXTRACT(dayofweek FROM subq_21.metric_time__day) - 1) AS metric_time__extract_dow , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + metric_time__day + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,7 +51,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_SUB(CAST(subq_22.ds AS DATETIME), INTERVAL 14 day) = subq_20.metric_time__day + DATE_SUB(CAST(subq_21.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_20.metric_time__day GROUP BY metric_time__extract_dow ) subq_26 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_grain_to_date_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_grain_to_date_metric__plan0.sql index a9629ffe48..7a5f98b311 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_grain_to_date_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_grain_to_date_metric__plan0.sql @@ -208,8 +208,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATETIME_TRUNC(subq_3.ts, hour) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + metric_time__hour ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql index c2c2880c4f..1ae6b31d6a 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql @@ -3,9 +3,16 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ts AS metric_time__hour + subq_9.metric_time__hour AS metric_time__hour , SUM(subq_8.archived_users) AS subdaily_cumulative_grain_to_date_metric -FROM ***************************.mf_time_spine_hour subq_10 +FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ts, hour) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_10 + GROUP BY + metric_time__hour +) subq_9 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -16,9 +23,9 @@ INNER JOIN ( ) subq_8 ON ( - subq_8.metric_time__hour <= subq_10.ts + subq_8.metric_time__hour <= subq_9.metric_time__hour ) AND ( - subq_8.metric_time__hour >= DATETIME_TRUNC(subq_10.ts, hour) + subq_8.metric_time__hour >= DATETIME_TRUNC(subq_9.metric_time__hour, hour) ) GROUP BY metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_window_metric__plan0.sql index 837b1fb254..d70411d985 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_window_metric__plan0.sql @@ -208,8 +208,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATETIME_TRUNC(subq_3.ts, hour) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + metric_time__hour ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_window_metric__plan0_optimized.sql index d5b1b0bc66..3c73c9ac98 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_window_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_cumulative_window_metric__plan0_optimized.sql @@ -3,9 +3,16 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ts AS metric_time__hour + subq_9.metric_time__hour AS metric_time__hour , SUM(subq_8.archived_users) AS subdaily_cumulative_window_metric -FROM ***************************.mf_time_spine_hour subq_10 +FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ts, hour) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_10 + GROUP BY + metric_time__hour +) subq_9 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -16,9 +23,9 @@ INNER JOIN ( ) subq_8 ON ( - subq_8.metric_time__hour <= subq_10.ts + subq_8.metric_time__hour <= subq_9.metric_time__hour ) AND ( - subq_8.metric_time__hour > DATE_SUB(CAST(subq_10.ts AS DATETIME), INTERVAL 3 hour) + subq_8.metric_time__hour > DATE_SUB(CAST(subq_9.metric_time__hour AS DATETIME), INTERVAL 3 hour) ) GROUP BY metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql index 371083d74c..00b83b22d3 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ts AS metric_time__hour + DATETIME_TRUNC(subq_5.ts, hour) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_5 + GROUP BY + metric_time__hour ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql index 97859a3220..4a9276002a 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql @@ -1,9 +1,16 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ts AS metric_time__hour + subq_11.metric_time__hour AS metric_time__hour , subq_10.archived_users AS subdaily_join_to_time_spine_metric -FROM ***************************.mf_time_spine_hour subq_12 +FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ts, hour) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_12 + GROUP BY + metric_time__hour +) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -22,4 +29,4 @@ LEFT OUTER JOIN ( metric_time__hour ) subq_10 ON - subq_12.ts = subq_10.metric_time__hour + subq_11.metric_time__hour = subq_10.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_join_to_time_spine_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_join_to_time_spine_metric__plan0.sql index 371083d74c..00b83b22d3 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_join_to_time_spine_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_join_to_time_spine_metric__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ts AS metric_time__hour + DATETIME_TRUNC(subq_5.ts, hour) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_5 + GROUP BY + metric_time__hour ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql index 97859a3220..4a9276002a 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql @@ -1,9 +1,16 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ts AS metric_time__hour + subq_11.metric_time__hour AS metric_time__hour , subq_10.archived_users AS subdaily_join_to_time_spine_metric -FROM ***************************.mf_time_spine_hour subq_12 +FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ts, hour) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_12 + GROUP BY + metric_time__hour +) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -22,4 +29,4 @@ LEFT OUTER JOIN ( metric_time__hour ) subq_10 ON - subq_12.ts = subq_10.metric_time__hour + subq_11.metric_time__hour = subq_10.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0.sql index 2dc17f03a4..d076a56775 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0.sql @@ -213,8 +213,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATETIME_TRUNC(subq_3.ts, hour) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + metric_time__hour ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0_optimized.sql index 82f176cfbe..a7bbda8904 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_to_grain_metric__plan0_optimized.sql @@ -8,9 +8,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ts AS metric_time__hour + subq_10.metric_time__hour AS metric_time__hour , SUM(subq_9.archived_users) AS archived_users - FROM ***************************.mf_time_spine_hour subq_11 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ts, hour) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_11 + GROUP BY + metric_time__hour + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -20,7 +27,7 @@ FROM ( FROM ***************************.dim_users users_ds_source_src_28000 ) subq_9 ON - DATETIME_TRUNC(subq_11.ts, hour) = subq_9.metric_time__hour + DATETIME_TRUNC(subq_10.metric_time__hour, hour) = subq_9.metric_time__hour GROUP BY metric_time__hour ) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_window_metric__plan0.sql index f25cd83b4a..bdb189b64a 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_window_metric__plan0.sql @@ -213,8 +213,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATETIME_TRUNC(subq_3.ts, hour) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + metric_time__hour ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_window_metric__plan0_optimized.sql index ee3ca01a8b..c6b483a2db 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_window_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_offset_window_metric__plan0_optimized.sql @@ -8,9 +8,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ts AS metric_time__hour + subq_10.metric_time__hour AS metric_time__hour , SUM(subq_9.archived_users) AS archived_users - FROM ***************************.mf_time_spine_hour subq_11 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ts, hour) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_11 + GROUP BY + metric_time__hour + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -20,7 +27,7 @@ FROM ( FROM ***************************.dim_users users_ds_source_src_28000 ) subq_9 ON - DATE_SUB(CAST(subq_11.ts AS DATETIME), INTERVAL 1 hour) = subq_9.metric_time__hour + DATE_SUB(CAST(subq_10.metric_time__hour AS DATETIME), INTERVAL 1 hour) = subq_9.metric_time__hour GROUP BY metric_time__hour ) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_time_constraint_with_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_time_constraint_with_metric__plan0.sql index 0bf53c189c..1cd8954fa4 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_time_constraint_with_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_time_constraint_with_metric__plan0.sql @@ -15,9 +15,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ts AS metric_time__hour + DATETIME_TRUNC(subq_6.ts, hour) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_6 WHERE subq_6.ts BETWEEN '2020-01-01 02:00:00' AND '2020-01-01 05:00:00' + GROUP BY + metric_time__hour ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_time_constraint_with_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_time_constraint_with_metric__plan0_optimized.sql index 527431e202..344be402f8 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_time_constraint_with_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/BigQuery/test_subdaily_time_constraint_with_metric__plan0_optimized.sql @@ -7,9 +7,11 @@ SELECT FROM ( -- Time Spine SELECT - ts AS metric_time__hour + DATETIME_TRUNC(ts, hour) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_15 WHERE ts BETWEEN '2020-01-01 02:00:00' AND '2020-01-01 05:00:00' + GROUP BY + metric_time__hour ) subq_14 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0.sql index 2320e8b134..6f37c77975 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0_optimized.sql index 7ce159c55f..f09f6c9122 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - EXTRACT(DAYOFWEEK_ISO FROM subq_22.ds) AS metric_time__extract_dow + EXTRACT(DAYOFWEEK_ISO FROM subq_21.metric_time__day) AS metric_time__extract_dow , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATEADD(day, -14, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -14, subq_21.metric_time__day) = subq_20.metric_time__day GROUP BY - EXTRACT(DAYOFWEEK_ISO FROM subq_22.ds) + EXTRACT(DAYOFWEEK_ISO FROM subq_21.metric_time__day) ) subq_26 ON subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_grain_to_date_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_grain_to_date_metric__plan0.sql index 79da25522b..8744a0b51a 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_grain_to_date_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_grain_to_date_metric__plan0.sql @@ -208,8 +208,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql index fe834fa9e6..6dc56e8981 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql @@ -3,9 +3,16 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ts AS metric_time__hour + subq_9.metric_time__hour AS metric_time__hour , SUM(subq_8.archived_users) AS subdaily_cumulative_grain_to_date_metric -FROM ***************************.mf_time_spine_hour subq_10 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_10 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_9 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -16,9 +23,9 @@ INNER JOIN ( ) subq_8 ON ( - subq_8.metric_time__hour <= subq_10.ts + subq_8.metric_time__hour <= subq_9.metric_time__hour ) AND ( - subq_8.metric_time__hour >= DATE_TRUNC('hour', subq_10.ts) + subq_8.metric_time__hour >= DATE_TRUNC('hour', subq_9.metric_time__hour) ) GROUP BY - subq_10.ts + subq_9.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_window_metric__plan0.sql index bf8eb1e375..35cb620dc0 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_window_metric__plan0.sql @@ -208,8 +208,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_window_metric__plan0_optimized.sql index 383af54854..8c6a873de6 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_window_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_cumulative_window_metric__plan0_optimized.sql @@ -3,9 +3,16 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ts AS metric_time__hour + subq_9.metric_time__hour AS metric_time__hour , SUM(subq_8.archived_users) AS subdaily_cumulative_window_metric -FROM ***************************.mf_time_spine_hour subq_10 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_10 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_9 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -16,9 +23,9 @@ INNER JOIN ( ) subq_8 ON ( - subq_8.metric_time__hour <= subq_10.ts + subq_8.metric_time__hour <= subq_9.metric_time__hour ) AND ( - subq_8.metric_time__hour > DATEADD(hour, -3, subq_10.ts) + subq_8.metric_time__hour > DATEADD(hour, -3, subq_9.metric_time__hour) ) GROUP BY - subq_10.ts + subq_9.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql index 7968c03d70..3e40516260 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ts AS metric_time__hour + DATE_TRUNC('hour', subq_5.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_5 + GROUP BY + DATE_TRUNC('hour', subq_5.ts) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql index 44763c6b6e..cd1bc0eaea 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql @@ -1,9 +1,16 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ts AS metric_time__hour + subq_11.metric_time__hour AS metric_time__hour , subq_10.archived_users AS subdaily_join_to_time_spine_metric -FROM ***************************.mf_time_spine_hour subq_12 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_12 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -22,4 +29,4 @@ LEFT OUTER JOIN ( metric_time__hour ) subq_10 ON - subq_12.ts = subq_10.metric_time__hour + subq_11.metric_time__hour = subq_10.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_join_to_time_spine_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_join_to_time_spine_metric__plan0.sql index 7968c03d70..3e40516260 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_join_to_time_spine_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_join_to_time_spine_metric__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ts AS metric_time__hour + DATE_TRUNC('hour', subq_5.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_5 + GROUP BY + DATE_TRUNC('hour', subq_5.ts) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql index 44763c6b6e..cd1bc0eaea 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql @@ -1,9 +1,16 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ts AS metric_time__hour + subq_11.metric_time__hour AS metric_time__hour , subq_10.archived_users AS subdaily_join_to_time_spine_metric -FROM ***************************.mf_time_spine_hour subq_12 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_12 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -22,4 +29,4 @@ LEFT OUTER JOIN ( metric_time__hour ) subq_10 ON - subq_12.ts = subq_10.metric_time__hour + subq_11.metric_time__hour = subq_10.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0.sql index 656b76a7f9..435f1ef902 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0.sql @@ -213,8 +213,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0_optimized.sql index 2679104380..4ed2614091 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_to_grain_metric__plan0_optimized.sql @@ -8,9 +8,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ts AS metric_time__hour + subq_10.metric_time__hour AS metric_time__hour , SUM(subq_9.archived_users) AS archived_users - FROM ***************************.mf_time_spine_hour subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_11 + GROUP BY + DATE_TRUNC('hour', ts) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -20,7 +27,7 @@ FROM ( FROM ***************************.dim_users users_ds_source_src_28000 ) subq_9 ON - DATE_TRUNC('hour', subq_11.ts) = subq_9.metric_time__hour + DATE_TRUNC('hour', subq_10.metric_time__hour) = subq_9.metric_time__hour GROUP BY - subq_11.ts + subq_10.metric_time__hour ) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_window_metric__plan0.sql index 7f24f79da5..53944170b3 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_window_metric__plan0.sql @@ -213,8 +213,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_window_metric__plan0_optimized.sql index c1f150dd0c..2ef2ee525c 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_window_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_offset_window_metric__plan0_optimized.sql @@ -8,9 +8,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ts AS metric_time__hour + subq_10.metric_time__hour AS metric_time__hour , SUM(subq_9.archived_users) AS archived_users - FROM ***************************.mf_time_spine_hour subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_11 + GROUP BY + DATE_TRUNC('hour', ts) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -20,7 +27,7 @@ FROM ( FROM ***************************.dim_users users_ds_source_src_28000 ) subq_9 ON - DATEADD(hour, -1, subq_11.ts) = subq_9.metric_time__hour + DATEADD(hour, -1, subq_10.metric_time__hour) = subq_9.metric_time__hour GROUP BY - subq_11.ts + subq_10.metric_time__hour ) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_time_constraint_with_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_time_constraint_with_metric__plan0.sql index 5e2ec2cb9c..b96701ba5f 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_time_constraint_with_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_time_constraint_with_metric__plan0.sql @@ -15,9 +15,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ts AS metric_time__hour + DATE_TRUNC('hour', subq_6.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_6 WHERE subq_6.ts BETWEEN '2020-01-01 02:00:00' AND '2020-01-01 05:00:00' + GROUP BY + DATE_TRUNC('hour', subq_6.ts) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_time_constraint_with_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_time_constraint_with_metric__plan0_optimized.sql index 7fef407456..640fbba6f2 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_time_constraint_with_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Databricks/test_subdaily_time_constraint_with_metric__plan0_optimized.sql @@ -7,9 +7,11 @@ SELECT FROM ( -- Time Spine SELECT - ts AS metric_time__hour + DATE_TRUNC('hour', ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_15 WHERE ts BETWEEN '2020-01-01 02:00:00' AND '2020-01-01 05:00:00' + GROUP BY + DATE_TRUNC('hour', ts) ) subq_14 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0.sql index 7229cf2062..6f75bf4086 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0_optimized.sql index f231ddabfd..554def85cb 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - EXTRACT(isodow FROM subq_22.ds) AS metric_time__extract_dow + EXTRACT(isodow FROM subq_21.metric_time__day) AS metric_time__extract_dow , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - subq_22.ds - MAKE_INTERVAL(days => 14) = subq_20.metric_time__day + subq_21.metric_time__day - MAKE_INTERVAL(days => 14) = subq_20.metric_time__day GROUP BY - EXTRACT(isodow FROM subq_22.ds) + EXTRACT(isodow FROM subq_21.metric_time__day) ) subq_26 ON subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_grain_to_date_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_grain_to_date_metric__plan0.sql index 1a252f2ebe..d10f754f77 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_grain_to_date_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_grain_to_date_metric__plan0.sql @@ -208,8 +208,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql index fe834fa9e6..6dc56e8981 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql @@ -3,9 +3,16 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ts AS metric_time__hour + subq_9.metric_time__hour AS metric_time__hour , SUM(subq_8.archived_users) AS subdaily_cumulative_grain_to_date_metric -FROM ***************************.mf_time_spine_hour subq_10 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_10 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_9 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -16,9 +23,9 @@ INNER JOIN ( ) subq_8 ON ( - subq_8.metric_time__hour <= subq_10.ts + subq_8.metric_time__hour <= subq_9.metric_time__hour ) AND ( - subq_8.metric_time__hour >= DATE_TRUNC('hour', subq_10.ts) + subq_8.metric_time__hour >= DATE_TRUNC('hour', subq_9.metric_time__hour) ) GROUP BY - subq_10.ts + subq_9.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_window_metric__plan0.sql index c4cdff003c..a2c2e5a77f 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_window_metric__plan0.sql @@ -208,8 +208,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_window_metric__plan0_optimized.sql index 86828264bb..167bb33b98 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_window_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_cumulative_window_metric__plan0_optimized.sql @@ -3,9 +3,16 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ts AS metric_time__hour + subq_9.metric_time__hour AS metric_time__hour , SUM(subq_8.archived_users) AS subdaily_cumulative_window_metric -FROM ***************************.mf_time_spine_hour subq_10 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_10 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_9 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -16,9 +23,9 @@ INNER JOIN ( ) subq_8 ON ( - subq_8.metric_time__hour <= subq_10.ts + subq_8.metric_time__hour <= subq_9.metric_time__hour ) AND ( - subq_8.metric_time__hour > subq_10.ts - MAKE_INTERVAL(hours => 3) + subq_8.metric_time__hour > subq_9.metric_time__hour - MAKE_INTERVAL(hours => 3) ) GROUP BY - subq_10.ts + subq_9.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql index fe488e80ff..ba6f2d7ccd 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ts AS metric_time__hour + DATE_TRUNC('hour', subq_5.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_5 + GROUP BY + DATE_TRUNC('hour', subq_5.ts) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql index 44763c6b6e..cd1bc0eaea 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql @@ -1,9 +1,16 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ts AS metric_time__hour + subq_11.metric_time__hour AS metric_time__hour , subq_10.archived_users AS subdaily_join_to_time_spine_metric -FROM ***************************.mf_time_spine_hour subq_12 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_12 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -22,4 +29,4 @@ LEFT OUTER JOIN ( metric_time__hour ) subq_10 ON - subq_12.ts = subq_10.metric_time__hour + subq_11.metric_time__hour = subq_10.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_join_to_time_spine_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_join_to_time_spine_metric__plan0.sql index fe488e80ff..ba6f2d7ccd 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_join_to_time_spine_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_join_to_time_spine_metric__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ts AS metric_time__hour + DATE_TRUNC('hour', subq_5.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_5 + GROUP BY + DATE_TRUNC('hour', subq_5.ts) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql index 44763c6b6e..cd1bc0eaea 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql @@ -1,9 +1,16 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ts AS metric_time__hour + subq_11.metric_time__hour AS metric_time__hour , subq_10.archived_users AS subdaily_join_to_time_spine_metric -FROM ***************************.mf_time_spine_hour subq_12 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_12 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -22,4 +29,4 @@ LEFT OUTER JOIN ( metric_time__hour ) subq_10 ON - subq_12.ts = subq_10.metric_time__hour + subq_11.metric_time__hour = subq_10.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0.sql index d30be670b4..a0f6d69c3a 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0.sql @@ -213,8 +213,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0_optimized.sql index 2679104380..4ed2614091 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_to_grain_metric__plan0_optimized.sql @@ -8,9 +8,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ts AS metric_time__hour + subq_10.metric_time__hour AS metric_time__hour , SUM(subq_9.archived_users) AS archived_users - FROM ***************************.mf_time_spine_hour subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_11 + GROUP BY + DATE_TRUNC('hour', ts) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -20,7 +27,7 @@ FROM ( FROM ***************************.dim_users users_ds_source_src_28000 ) subq_9 ON - DATE_TRUNC('hour', subq_11.ts) = subq_9.metric_time__hour + DATE_TRUNC('hour', subq_10.metric_time__hour) = subq_9.metric_time__hour GROUP BY - subq_11.ts + subq_10.metric_time__hour ) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_window_metric__plan0.sql index 86e2ae8260..b65928772b 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_window_metric__plan0.sql @@ -213,8 +213,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_window_metric__plan0_optimized.sql index 4481a4f63b..7554a2d254 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_window_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_offset_window_metric__plan0_optimized.sql @@ -8,9 +8,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ts AS metric_time__hour + subq_10.metric_time__hour AS metric_time__hour , SUM(subq_9.archived_users) AS archived_users - FROM ***************************.mf_time_spine_hour subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_11 + GROUP BY + DATE_TRUNC('hour', ts) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -20,7 +27,7 @@ FROM ( FROM ***************************.dim_users users_ds_source_src_28000 ) subq_9 ON - subq_11.ts - MAKE_INTERVAL(hours => 1) = subq_9.metric_time__hour + subq_10.metric_time__hour - MAKE_INTERVAL(hours => 1) = subq_9.metric_time__hour GROUP BY - subq_11.ts + subq_10.metric_time__hour ) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_time_constraint_with_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_time_constraint_with_metric__plan0.sql index f1543cd157..7bceed2c3f 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_time_constraint_with_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_time_constraint_with_metric__plan0.sql @@ -15,9 +15,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ts AS metric_time__hour + DATE_TRUNC('hour', subq_6.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_6 WHERE subq_6.ts BETWEEN '2020-01-01 02:00:00' AND '2020-01-01 05:00:00' + GROUP BY + DATE_TRUNC('hour', subq_6.ts) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_time_constraint_with_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_time_constraint_with_metric__plan0_optimized.sql index 7fef407456..640fbba6f2 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_time_constraint_with_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Postgres/test_subdaily_time_constraint_with_metric__plan0_optimized.sql @@ -7,9 +7,11 @@ SELECT FROM ( -- Time Spine SELECT - ts AS metric_time__hour + DATE_TRUNC('hour', ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_15 WHERE ts BETWEEN '2020-01-01 02:00:00' AND '2020-01-01 05:00:00' + GROUP BY + DATE_TRUNC('hour', ts) ) subq_14 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0.sql index a6a4c2d5f9..e0be5e2f6b 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0_optimized.sql index 4829b102ed..6a539f74db 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - 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 AS metric_time__extract_dow + CASE WHEN EXTRACT(dow FROM subq_21.metric_time__day) = 0 THEN EXTRACT(dow FROM subq_21.metric_time__day) + 7 ELSE EXTRACT(dow FROM subq_21.metric_time__day) END AS metric_time__extract_dow , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATEADD(day, -14, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -14, subq_21.metric_time__day) = subq_20.metric_time__day GROUP BY - 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 + CASE WHEN EXTRACT(dow FROM subq_21.metric_time__day) = 0 THEN EXTRACT(dow FROM subq_21.metric_time__day) + 7 ELSE EXTRACT(dow FROM subq_21.metric_time__day) END ) subq_26 ON subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_grain_to_date_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_grain_to_date_metric__plan0.sql index 4ef0598915..10024cceac 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_grain_to_date_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_grain_to_date_metric__plan0.sql @@ -208,8 +208,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql index fe834fa9e6..6dc56e8981 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql @@ -3,9 +3,16 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ts AS metric_time__hour + subq_9.metric_time__hour AS metric_time__hour , SUM(subq_8.archived_users) AS subdaily_cumulative_grain_to_date_metric -FROM ***************************.mf_time_spine_hour subq_10 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_10 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_9 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -16,9 +23,9 @@ INNER JOIN ( ) subq_8 ON ( - subq_8.metric_time__hour <= subq_10.ts + subq_8.metric_time__hour <= subq_9.metric_time__hour ) AND ( - subq_8.metric_time__hour >= DATE_TRUNC('hour', subq_10.ts) + subq_8.metric_time__hour >= DATE_TRUNC('hour', subq_9.metric_time__hour) ) GROUP BY - subq_10.ts + subq_9.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_window_metric__plan0.sql index 1d47d605da..98eaf9bb02 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_window_metric__plan0.sql @@ -208,8 +208,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_window_metric__plan0_optimized.sql index 383af54854..8c6a873de6 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_window_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_cumulative_window_metric__plan0_optimized.sql @@ -3,9 +3,16 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ts AS metric_time__hour + subq_9.metric_time__hour AS metric_time__hour , SUM(subq_8.archived_users) AS subdaily_cumulative_window_metric -FROM ***************************.mf_time_spine_hour subq_10 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_10 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_9 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -16,9 +23,9 @@ INNER JOIN ( ) subq_8 ON ( - subq_8.metric_time__hour <= subq_10.ts + subq_8.metric_time__hour <= subq_9.metric_time__hour ) AND ( - subq_8.metric_time__hour > DATEADD(hour, -3, subq_10.ts) + subq_8.metric_time__hour > DATEADD(hour, -3, subq_9.metric_time__hour) ) GROUP BY - subq_10.ts + subq_9.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql index b20cb0d168..ceab07672b 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ts AS metric_time__hour + DATE_TRUNC('hour', subq_5.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_5 + GROUP BY + DATE_TRUNC('hour', subq_5.ts) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql index 44763c6b6e..cd1bc0eaea 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql @@ -1,9 +1,16 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ts AS metric_time__hour + subq_11.metric_time__hour AS metric_time__hour , subq_10.archived_users AS subdaily_join_to_time_spine_metric -FROM ***************************.mf_time_spine_hour subq_12 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_12 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -22,4 +29,4 @@ LEFT OUTER JOIN ( metric_time__hour ) subq_10 ON - subq_12.ts = subq_10.metric_time__hour + subq_11.metric_time__hour = subq_10.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_join_to_time_spine_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_join_to_time_spine_metric__plan0.sql index b20cb0d168..ceab07672b 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_join_to_time_spine_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_join_to_time_spine_metric__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ts AS metric_time__hour + DATE_TRUNC('hour', subq_5.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_5 + GROUP BY + DATE_TRUNC('hour', subq_5.ts) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql index 44763c6b6e..cd1bc0eaea 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql @@ -1,9 +1,16 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ts AS metric_time__hour + subq_11.metric_time__hour AS metric_time__hour , subq_10.archived_users AS subdaily_join_to_time_spine_metric -FROM ***************************.mf_time_spine_hour subq_12 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_12 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -22,4 +29,4 @@ LEFT OUTER JOIN ( metric_time__hour ) subq_10 ON - subq_12.ts = subq_10.metric_time__hour + subq_11.metric_time__hour = subq_10.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0.sql index 3cbe377614..1d923a0abc 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0.sql @@ -213,8 +213,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0_optimized.sql index 2679104380..4ed2614091 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_to_grain_metric__plan0_optimized.sql @@ -8,9 +8,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ts AS metric_time__hour + subq_10.metric_time__hour AS metric_time__hour , SUM(subq_9.archived_users) AS archived_users - FROM ***************************.mf_time_spine_hour subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_11 + GROUP BY + DATE_TRUNC('hour', ts) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -20,7 +27,7 @@ FROM ( FROM ***************************.dim_users users_ds_source_src_28000 ) subq_9 ON - DATE_TRUNC('hour', subq_11.ts) = subq_9.metric_time__hour + DATE_TRUNC('hour', subq_10.metric_time__hour) = subq_9.metric_time__hour GROUP BY - subq_11.ts + subq_10.metric_time__hour ) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_window_metric__plan0.sql index 06128e25e6..a168cb42a8 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_window_metric__plan0.sql @@ -213,8 +213,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_window_metric__plan0_optimized.sql index c1f150dd0c..2ef2ee525c 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_window_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_offset_window_metric__plan0_optimized.sql @@ -8,9 +8,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ts AS metric_time__hour + subq_10.metric_time__hour AS metric_time__hour , SUM(subq_9.archived_users) AS archived_users - FROM ***************************.mf_time_spine_hour subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_11 + GROUP BY + DATE_TRUNC('hour', ts) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -20,7 +27,7 @@ FROM ( FROM ***************************.dim_users users_ds_source_src_28000 ) subq_9 ON - DATEADD(hour, -1, subq_11.ts) = subq_9.metric_time__hour + DATEADD(hour, -1, subq_10.metric_time__hour) = subq_9.metric_time__hour GROUP BY - subq_11.ts + subq_10.metric_time__hour ) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_time_constraint_with_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_time_constraint_with_metric__plan0.sql index de5289af50..b390b02b86 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_time_constraint_with_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_time_constraint_with_metric__plan0.sql @@ -15,9 +15,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ts AS metric_time__hour + DATE_TRUNC('hour', subq_6.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_6 WHERE subq_6.ts BETWEEN '2020-01-01 02:00:00' AND '2020-01-01 05:00:00' + GROUP BY + DATE_TRUNC('hour', subq_6.ts) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_time_constraint_with_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_time_constraint_with_metric__plan0_optimized.sql index 7fef407456..640fbba6f2 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_time_constraint_with_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Redshift/test_subdaily_time_constraint_with_metric__plan0_optimized.sql @@ -7,9 +7,11 @@ SELECT FROM ( -- Time Spine SELECT - ts AS metric_time__hour + DATE_TRUNC('hour', ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_15 WHERE ts BETWEEN '2020-01-01 02:00:00' AND '2020-01-01 05:00:00' + GROUP BY + DATE_TRUNC('hour', ts) ) subq_14 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0.sql index 9ebe5b940a..c4b61ee192 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0_optimized.sql index d181746878..0122aa5fa8 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - EXTRACT(dayofweekiso FROM subq_22.ds) AS metric_time__extract_dow + EXTRACT(dayofweekiso FROM subq_21.metric_time__day) AS metric_time__extract_dow , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATEADD(day, -14, subq_22.ds) = subq_20.metric_time__day + DATEADD(day, -14, subq_21.metric_time__day) = subq_20.metric_time__day GROUP BY - EXTRACT(dayofweekiso FROM subq_22.ds) + EXTRACT(dayofweekiso FROM subq_21.metric_time__day) ) subq_26 ON subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_grain_to_date_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_grain_to_date_metric__plan0.sql index 23c7ebf08d..f143c7e8de 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_grain_to_date_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_grain_to_date_metric__plan0.sql @@ -208,8 +208,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql index fe834fa9e6..6dc56e8981 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql @@ -3,9 +3,16 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ts AS metric_time__hour + subq_9.metric_time__hour AS metric_time__hour , SUM(subq_8.archived_users) AS subdaily_cumulative_grain_to_date_metric -FROM ***************************.mf_time_spine_hour subq_10 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_10 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_9 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -16,9 +23,9 @@ INNER JOIN ( ) subq_8 ON ( - subq_8.metric_time__hour <= subq_10.ts + subq_8.metric_time__hour <= subq_9.metric_time__hour ) AND ( - subq_8.metric_time__hour >= DATE_TRUNC('hour', subq_10.ts) + subq_8.metric_time__hour >= DATE_TRUNC('hour', subq_9.metric_time__hour) ) GROUP BY - subq_10.ts + subq_9.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_window_metric__plan0.sql index 3f7f85a176..95004f0df5 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_window_metric__plan0.sql @@ -208,8 +208,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_window_metric__plan0_optimized.sql index 383af54854..8c6a873de6 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_window_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_cumulative_window_metric__plan0_optimized.sql @@ -3,9 +3,16 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ts AS metric_time__hour + subq_9.metric_time__hour AS metric_time__hour , SUM(subq_8.archived_users) AS subdaily_cumulative_window_metric -FROM ***************************.mf_time_spine_hour subq_10 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_10 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_9 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -16,9 +23,9 @@ INNER JOIN ( ) subq_8 ON ( - subq_8.metric_time__hour <= subq_10.ts + subq_8.metric_time__hour <= subq_9.metric_time__hour ) AND ( - subq_8.metric_time__hour > DATEADD(hour, -3, subq_10.ts) + subq_8.metric_time__hour > DATEADD(hour, -3, subq_9.metric_time__hour) ) GROUP BY - subq_10.ts + subq_9.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql index 1da20491ef..af00dcf709 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ts AS metric_time__hour + DATE_TRUNC('hour', subq_5.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_5 + GROUP BY + DATE_TRUNC('hour', subq_5.ts) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql index 44763c6b6e..cd1bc0eaea 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql @@ -1,9 +1,16 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ts AS metric_time__hour + subq_11.metric_time__hour AS metric_time__hour , subq_10.archived_users AS subdaily_join_to_time_spine_metric -FROM ***************************.mf_time_spine_hour subq_12 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_12 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -22,4 +29,4 @@ LEFT OUTER JOIN ( metric_time__hour ) subq_10 ON - subq_12.ts = subq_10.metric_time__hour + subq_11.metric_time__hour = subq_10.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_join_to_time_spine_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_join_to_time_spine_metric__plan0.sql index 1da20491ef..af00dcf709 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_join_to_time_spine_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_join_to_time_spine_metric__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ts AS metric_time__hour + DATE_TRUNC('hour', subq_5.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_5 + GROUP BY + DATE_TRUNC('hour', subq_5.ts) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql index 44763c6b6e..cd1bc0eaea 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql @@ -1,9 +1,16 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ts AS metric_time__hour + subq_11.metric_time__hour AS metric_time__hour , subq_10.archived_users AS subdaily_join_to_time_spine_metric -FROM ***************************.mf_time_spine_hour subq_12 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_12 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -22,4 +29,4 @@ LEFT OUTER JOIN ( metric_time__hour ) subq_10 ON - subq_12.ts = subq_10.metric_time__hour + subq_11.metric_time__hour = subq_10.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0.sql index b127b9b063..5d13c087ea 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0.sql @@ -213,8 +213,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0_optimized.sql index 2679104380..4ed2614091 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_to_grain_metric__plan0_optimized.sql @@ -8,9 +8,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ts AS metric_time__hour + subq_10.metric_time__hour AS metric_time__hour , SUM(subq_9.archived_users) AS archived_users - FROM ***************************.mf_time_spine_hour subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_11 + GROUP BY + DATE_TRUNC('hour', ts) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -20,7 +27,7 @@ FROM ( FROM ***************************.dim_users users_ds_source_src_28000 ) subq_9 ON - DATE_TRUNC('hour', subq_11.ts) = subq_9.metric_time__hour + DATE_TRUNC('hour', subq_10.metric_time__hour) = subq_9.metric_time__hour GROUP BY - subq_11.ts + subq_10.metric_time__hour ) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_window_metric__plan0.sql index af61bc2907..0acac89fe6 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_window_metric__plan0.sql @@ -213,8 +213,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_window_metric__plan0_optimized.sql index c1f150dd0c..2ef2ee525c 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_window_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_offset_window_metric__plan0_optimized.sql @@ -8,9 +8,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ts AS metric_time__hour + subq_10.metric_time__hour AS metric_time__hour , SUM(subq_9.archived_users) AS archived_users - FROM ***************************.mf_time_spine_hour subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_11 + GROUP BY + DATE_TRUNC('hour', ts) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -20,7 +27,7 @@ FROM ( FROM ***************************.dim_users users_ds_source_src_28000 ) subq_9 ON - DATEADD(hour, -1, subq_11.ts) = subq_9.metric_time__hour + DATEADD(hour, -1, subq_10.metric_time__hour) = subq_9.metric_time__hour GROUP BY - subq_11.ts + subq_10.metric_time__hour ) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_time_constraint_with_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_time_constraint_with_metric__plan0.sql index 2b3ee9b379..ff0bcddbbb 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_time_constraint_with_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_time_constraint_with_metric__plan0.sql @@ -15,9 +15,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ts AS metric_time__hour + DATE_TRUNC('hour', subq_6.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_6 WHERE subq_6.ts BETWEEN '2020-01-01 02:00:00' AND '2020-01-01 05:00:00' + GROUP BY + DATE_TRUNC('hour', subq_6.ts) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_time_constraint_with_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_time_constraint_with_metric__plan0_optimized.sql index 7fef407456..640fbba6f2 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_time_constraint_with_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Snowflake/test_subdaily_time_constraint_with_metric__plan0_optimized.sql @@ -7,9 +7,11 @@ SELECT FROM ( -- Time Spine SELECT - ts AS metric_time__hour + DATE_TRUNC('hour', ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_15 WHERE ts BETWEEN '2020-01-01 02:00:00' AND '2020-01-01 05:00:00' + GROUP BY + DATE_TRUNC('hour', ts) ) subq_14 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0.sql index eacfae4235..a596540a67 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0.sql @@ -342,8 +342,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('day', subq_8.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_8 + GROUP BY + DATE_TRUNC('day', subq_8.ds) ) subq_7 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0_optimized.sql index 7cf9240bf9..e3de14b6c7 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_offset_window_with_date_part__plan0_optimized.sql @@ -32,9 +32,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - EXTRACT(DAY_OF_WEEK FROM subq_22.ds) AS metric_time__extract_dow + EXTRACT(DAY_OF_WEEK FROM subq_21.metric_time__day) AS metric_time__extract_dow , SUM(subq_20.bookings) AS bookings_2_weeks_ago - FROM ***************************.mf_time_spine subq_22 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_22 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_21 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -44,9 +51,9 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_20 ON - DATE_ADD('day', -14, subq_22.ds) = subq_20.metric_time__day + DATE_ADD('day', -14, subq_21.metric_time__day) = subq_20.metric_time__day GROUP BY - EXTRACT(DAY_OF_WEEK FROM subq_22.ds) + EXTRACT(DAY_OF_WEEK FROM subq_21.metric_time__day) ) subq_26 ON subq_18.metric_time__extract_dow = subq_26.metric_time__extract_dow diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_grain_to_date_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_grain_to_date_metric__plan0.sql index b1e2e5d581..31f4264b0c 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_grain_to_date_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_grain_to_date_metric__plan0.sql @@ -208,8 +208,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql index fe834fa9e6..6dc56e8981 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_grain_to_date_metric__plan0_optimized.sql @@ -3,9 +3,16 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ts AS metric_time__hour + subq_9.metric_time__hour AS metric_time__hour , SUM(subq_8.archived_users) AS subdaily_cumulative_grain_to_date_metric -FROM ***************************.mf_time_spine_hour subq_10 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_10 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_9 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -16,9 +23,9 @@ INNER JOIN ( ) subq_8 ON ( - subq_8.metric_time__hour <= subq_10.ts + subq_8.metric_time__hour <= subq_9.metric_time__hour ) AND ( - subq_8.metric_time__hour >= DATE_TRUNC('hour', subq_10.ts) + subq_8.metric_time__hour >= DATE_TRUNC('hour', subq_9.metric_time__hour) ) GROUP BY - subq_10.ts + subq_9.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_window_metric__plan0.sql index 56dd014810..19221b1b6b 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_window_metric__plan0.sql @@ -208,8 +208,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_window_metric__plan0_optimized.sql index 38bf90d047..7999fd2207 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_window_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_cumulative_window_metric__plan0_optimized.sql @@ -3,9 +3,16 @@ -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_10.ts AS metric_time__hour + subq_9.metric_time__hour AS metric_time__hour , SUM(subq_8.archived_users) AS subdaily_cumulative_window_metric -FROM ***************************.mf_time_spine_hour subq_10 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_10 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_9 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -16,9 +23,9 @@ INNER JOIN ( ) subq_8 ON ( - subq_8.metric_time__hour <= subq_10.ts + subq_8.metric_time__hour <= subq_9.metric_time__hour ) AND ( - subq_8.metric_time__hour > DATE_ADD('hour', -3, subq_10.ts) + subq_8.metric_time__hour > DATE_ADD('hour', -3, subq_9.metric_time__hour) ) GROUP BY - subq_10.ts + subq_9.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql index 8d782a8799..ecb02f299c 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_granularity_overrides_metric_default_granularity__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ts AS metric_time__hour + DATE_TRUNC('hour', subq_5.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_5 + GROUP BY + DATE_TRUNC('hour', subq_5.ts) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql index 44763c6b6e..cd1bc0eaea 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_granularity_overrides_metric_default_granularity__plan0_optimized.sql @@ -1,9 +1,16 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ts AS metric_time__hour + subq_11.metric_time__hour AS metric_time__hour , subq_10.archived_users AS subdaily_join_to_time_spine_metric -FROM ***************************.mf_time_spine_hour subq_12 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_12 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -22,4 +29,4 @@ LEFT OUTER JOIN ( metric_time__hour ) subq_10 ON - subq_12.ts = subq_10.metric_time__hour + subq_11.metric_time__hour = subq_10.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_join_to_time_spine_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_join_to_time_spine_metric__plan0.sql index 8d782a8799..ecb02f299c 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_join_to_time_spine_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_join_to_time_spine_metric__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ts AS metric_time__hour + DATE_TRUNC('hour', subq_5.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_5 + GROUP BY + DATE_TRUNC('hour', subq_5.ts) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql index 44763c6b6e..cd1bc0eaea 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_join_to_time_spine_metric__plan0_optimized.sql @@ -1,9 +1,16 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ts AS metric_time__hour + subq_11.metric_time__hour AS metric_time__hour , subq_10.archived_users AS subdaily_join_to_time_spine_metric -FROM ***************************.mf_time_spine_hour subq_12 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_12 + GROUP BY + DATE_TRUNC('hour', ts) +) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -22,4 +29,4 @@ LEFT OUTER JOIN ( metric_time__hour ) subq_10 ON - subq_12.ts = subq_10.metric_time__hour + subq_11.metric_time__hour = subq_10.metric_time__hour diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_to_grain_metric__plan0.sql index 3f01692015..a00eada3f1 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_to_grain_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_to_grain_metric__plan0.sql @@ -213,8 +213,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_to_grain_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_to_grain_metric__plan0_optimized.sql index 2679104380..4ed2614091 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_to_grain_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_to_grain_metric__plan0_optimized.sql @@ -8,9 +8,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ts AS metric_time__hour + subq_10.metric_time__hour AS metric_time__hour , SUM(subq_9.archived_users) AS archived_users - FROM ***************************.mf_time_spine_hour subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_11 + GROUP BY + DATE_TRUNC('hour', ts) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -20,7 +27,7 @@ FROM ( FROM ***************************.dim_users users_ds_source_src_28000 ) subq_9 ON - DATE_TRUNC('hour', subq_11.ts) = subq_9.metric_time__hour + DATE_TRUNC('hour', subq_10.metric_time__hour) = subq_9.metric_time__hour GROUP BY - subq_11.ts + subq_10.metric_time__hour ) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_window_metric__plan0.sql index cbf1be1e9d..6bc0242a8b 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_window_metric__plan0.sql @@ -213,8 +213,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ts AS metric_time__hour + DATE_TRUNC('hour', subq_3.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_3 + GROUP BY + DATE_TRUNC('hour', subq_3.ts) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'archived_at' diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_window_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_window_metric__plan0_optimized.sql index 70b55ba01d..2748833710 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_window_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_offset_window_metric__plan0_optimized.sql @@ -8,9 +8,16 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ts AS metric_time__hour + subq_10.metric_time__hour AS metric_time__hour , SUM(subq_9.archived_users) AS archived_users - FROM ***************************.mf_time_spine_hour subq_11 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('hour', ts) AS metric_time__hour + FROM ***************************.mf_time_spine_hour subq_11 + GROUP BY + DATE_TRUNC('hour', ts) + ) subq_10 INNER JOIN ( -- Read Elements From Semantic Model 'users_ds_source' -- Metric Time Dimension 'archived_at' @@ -20,7 +27,7 @@ FROM ( FROM ***************************.dim_users users_ds_source_src_28000 ) subq_9 ON - DATE_ADD('hour', -1, subq_11.ts) = subq_9.metric_time__hour + DATE_ADD('hour', -1, subq_10.metric_time__hour) = subq_9.metric_time__hour GROUP BY - subq_11.ts + subq_10.metric_time__hour ) subq_15 diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_time_constraint_with_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_time_constraint_with_metric__plan0.sql index 8a6984d97e..4b7e66751c 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_time_constraint_with_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_time_constraint_with_metric__plan0.sql @@ -15,9 +15,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ts AS metric_time__hour + DATE_TRUNC('hour', subq_6.ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_6 WHERE subq_6.ts BETWEEN timestamp '2020-01-01 02:00:00' AND timestamp '2020-01-01 05:00:00' + GROUP BY + DATE_TRUNC('hour', subq_6.ts) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_time_constraint_with_metric__plan0_optimized.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_time_constraint_with_metric__plan0_optimized.sql index 62103ce318..0d3606010b 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_time_constraint_with_metric__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/Trino/test_subdaily_time_constraint_with_metric__plan0_optimized.sql @@ -7,9 +7,11 @@ SELECT FROM ( -- Time Spine SELECT - ts AS metric_time__hour + DATE_TRUNC('hour', ts) AS metric_time__hour FROM ***************************.mf_time_spine_hour subq_15 WHERE ts BETWEEN timestamp '2020-01-01 02:00:00' AND timestamp '2020-01-01 05:00:00' + GROUP BY + DATE_TRUNC('hour', ts) ) subq_14 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_query_time_filters__plan0.sql index b14b3141df..e9414f17e5 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_query_time_filters__plan0.sql @@ -148,8 +148,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATETIME_TRUNC(subq_3.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + metric_time__day ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql index 5b570bda0a..ed94f15ea1 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql @@ -11,10 +11,17 @@ FROM ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_18.ds AS metric_time__day + subq_17.metric_time__day AS metric_time__day , subq_16.listing AS listing , subq_16.bookers AS bookers - FROM ***************************.mf_time_spine subq_18 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_18 + GROUP BY + metric_time__day + ) subq_17 INNER JOIN ( -- Constrain Output with WHERE SELECT @@ -35,9 +42,9 @@ FROM ( ) subq_16 ON ( - subq_16.metric_time__day <= subq_18.ds + subq_16.metric_time__day <= subq_17.metric_time__day ) AND ( - subq_16.metric_time__day > DATE_SUB(CAST(subq_18.ds AS DATETIME), INTERVAL 2 day) + subq_16.metric_time__day > DATE_SUB(CAST(subq_17.metric_time__day AS DATETIME), INTERVAL 2 day) ) ) subq_20 LEFT OUTER JOIN diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index 76e3e3bf5d..8e39769500 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -25,8 +25,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_12.ds AS metric_time__day + DATETIME_TRUNC(subq_12.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_12 + GROUP BY + metric_time__day ) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures @@ -433,8 +435,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_30.ds AS metric_time__day + DATETIME_TRUNC(subq_30.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_30 + GROUP BY + metric_time__day ) subq_29 LEFT OUTER JOIN ( -- Aggregate Measures @@ -581,8 +585,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_18.ds AS metric_time__day + DATETIME_TRUNC(subq_18.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_18 + GROUP BY + metric_time__day ) subq_17 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql index 69b22f2109..b41fb08586 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql @@ -19,10 +19,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_46.ds AS metric_time__day + subq_45.metric_time__day AS metric_time__day , subq_44.listing__country_latest AS listing__country_latest , subq_44.bookings AS bookings - FROM ***************************.mf_time_spine subq_46 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_46 + GROUP BY + metric_time__day + ) subq_45 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] @@ -60,7 +67,7 @@ FROM ( , listing__country_latest ) subq_44 ON - subq_46.ds = subq_44.metric_time__day + subq_45.metric_time__day = subq_44.metric_time__day ) subq_47 ) subq_48 FULL OUTER JOIN ( @@ -72,10 +79,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_64.ds AS metric_time__day + subq_63.metric_time__day AS metric_time__day , subq_62.listing__country_latest AS listing__country_latest , subq_62.bookings AS bookings - FROM ***************************.mf_time_spine subq_64 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_64 + GROUP BY + metric_time__day + ) subq_63 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -96,11 +110,18 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_52.ds AS metric_time__day + subq_51.metric_time__day AS metric_time__day , subq_50.listing AS listing , subq_50.booking__is_instant AS booking__is_instant , subq_50.bookings AS bookings - FROM ***************************.mf_time_spine subq_52 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_52 + GROUP BY + metric_time__day + ) subq_51 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -112,7 +133,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_50 ON - DATE_SUB(CAST(subq_52.ds AS DATETIME), INTERVAL 14 day) = subq_50.metric_time__day + DATE_SUB(CAST(subq_51.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_50.metric_time__day ) subq_54 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 @@ -125,7 +146,7 @@ FROM ( , listing__country_latest ) subq_62 ON - subq_64.ds = subq_62.metric_time__day + subq_63.metric_time__day = subq_62.metric_time__day ) subq_65 ) subq_66 ON diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0.sql index ea15614ed2..6ae3d2e6a6 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0.sql @@ -554,8 +554,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_15.ds AS metric_time__day + DATETIME_TRUNC(subq_15.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_15 + GROUP BY + metric_time__day ) subq_14 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0_optimized.sql index 9a96aa08db..bd0a518ef1 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_offset_metric_with_query_time_filters__plan0_optimized.sql @@ -68,11 +68,18 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_43.ds AS metric_time__day + subq_42.metric_time__day AS metric_time__day , subq_41.listing AS listing , subq_41.booking__is_instant AS booking__is_instant , subq_41.bookings AS bookings - FROM ***************************.mf_time_spine subq_43 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_43 + GROUP BY + metric_time__day + ) subq_42 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -84,7 +91,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_41 ON - DATE_SUB(CAST(subq_43.ds AS DATETIME), INTERVAL 14 day) = subq_41.metric_time__day + DATE_SUB(CAST(subq_42.metric_time__day AS DATETIME), INTERVAL 14 day) = subq_41.metric_time__day ) subq_45 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql index c7235c2ca9..65041e9b3c 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql @@ -18,8 +18,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATETIME_TRUNC(subq_6.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_6 + GROUP BY + metric_time__day ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql index f1b60a40af..fa9ceb3396 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql @@ -7,10 +7,17 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , subq_13.booking__is_instant AS booking__is_instant , subq_13.bookings AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + metric_time__day + ) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -34,6 +41,6 @@ FROM ( , booking__is_instant ) subq_13 ON - subq_15.ds = subq_13.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day ) subq_16 WHERE booking__is_instant diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_query_time_filters__plan0.sql index 3f45fb8f0f..17aa74ac28 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_query_time_filters__plan0.sql @@ -148,8 +148,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql index a055d447cb..4f2e13c625 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql @@ -11,10 +11,17 @@ FROM ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_18.ds AS metric_time__day + subq_17.metric_time__day AS metric_time__day , subq_16.listing AS listing , subq_16.bookers AS bookers - FROM ***************************.mf_time_spine subq_18 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_17 INNER JOIN ( -- Constrain Output with WHERE SELECT @@ -35,9 +42,9 @@ FROM ( ) subq_16 ON ( - subq_16.metric_time__day <= subq_18.ds + subq_16.metric_time__day <= subq_17.metric_time__day ) AND ( - subq_16.metric_time__day > DATEADD(day, -2, subq_18.ds) + subq_16.metric_time__day > DATEADD(day, -2, subq_17.metric_time__day) ) ) subq_20 LEFT OUTER JOIN diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index ff2a2c2169..2125604c56 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -25,8 +25,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_12.ds AS metric_time__day + DATE_TRUNC('day', subq_12.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_12 + GROUP BY + DATE_TRUNC('day', subq_12.ds) ) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures @@ -433,8 +435,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_30.ds AS metric_time__day + DATE_TRUNC('day', subq_30.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_30 + GROUP BY + DATE_TRUNC('day', subq_30.ds) ) subq_29 LEFT OUTER JOIN ( -- Aggregate Measures @@ -581,8 +585,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_18.ds AS metric_time__day + DATE_TRUNC('day', subq_18.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', subq_18.ds) ) subq_17 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql index fa9dd7b4cb..e85d308155 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql @@ -19,10 +19,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_46.ds AS metric_time__day + subq_45.metric_time__day AS metric_time__day , subq_44.listing__country_latest AS listing__country_latest , subq_44.bookings AS bookings - FROM ***************************.mf_time_spine subq_46 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_46 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_45 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] @@ -60,7 +67,7 @@ FROM ( , listings_latest_src_28000.country ) subq_44 ON - subq_46.ds = subq_44.metric_time__day + subq_45.metric_time__day = subq_44.metric_time__day ) subq_47 ) subq_48 FULL OUTER JOIN ( @@ -72,10 +79,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_64.ds AS metric_time__day + subq_63.metric_time__day AS metric_time__day , subq_62.listing__country_latest AS listing__country_latest , subq_62.bookings AS bookings - FROM ***************************.mf_time_spine subq_64 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_64 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_63 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -96,11 +110,18 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_52.ds AS metric_time__day + subq_51.metric_time__day AS metric_time__day , subq_50.listing AS listing , subq_50.booking__is_instant AS booking__is_instant , subq_50.bookings AS bookings - FROM ***************************.mf_time_spine subq_52 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_52 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_51 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -112,7 +133,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_50 ON - DATEADD(day, -14, subq_52.ds) = subq_50.metric_time__day + DATEADD(day, -14, subq_51.metric_time__day) = subq_50.metric_time__day ) subq_54 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 @@ -125,7 +146,7 @@ FROM ( , listing__country_latest ) subq_62 ON - subq_64.ds = subq_62.metric_time__day + subq_63.metric_time__day = subq_62.metric_time__day ) subq_65 ) subq_66 ON diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_offset_metric_with_query_time_filters__plan0.sql index 031cbe720b..2a3cd56086 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_offset_metric_with_query_time_filters__plan0.sql @@ -554,8 +554,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_15.ds AS metric_time__day + DATE_TRUNC('day', subq_15.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', subq_15.ds) ) subq_14 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_offset_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_offset_metric_with_query_time_filters__plan0_optimized.sql index 1f66c755da..2046094e5b 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_offset_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_offset_metric_with_query_time_filters__plan0_optimized.sql @@ -68,11 +68,18 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_43.ds AS metric_time__day + subq_42.metric_time__day AS metric_time__day , subq_41.listing AS listing , subq_41.booking__is_instant AS booking__is_instant , subq_41.bookings AS bookings - FROM ***************************.mf_time_spine subq_43 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_43 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_42 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -84,7 +91,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_41 ON - DATEADD(day, -14, subq_43.ds) = subq_41.metric_time__day + DATEADD(day, -14, subq_42.metric_time__day) = subq_41.metric_time__day ) subq_45 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql index 2fc46046d3..f847b8548c 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql @@ -18,8 +18,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql index 8892599ad9..c97b53e629 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql @@ -7,10 +7,17 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , subq_13.booking__is_instant AS booking__is_instant , subq_13.bookings AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -34,6 +41,6 @@ FROM ( , booking__is_instant ) subq_13 ON - subq_15.ds = subq_13.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day ) subq_16 WHERE booking__is_instant diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_query_time_filters__plan0.sql index 83de7ff3ef..33c9cedfc0 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_query_time_filters__plan0.sql @@ -148,8 +148,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql index 91232f5296..e85dcbc566 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql @@ -11,10 +11,17 @@ FROM ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_18.ds AS metric_time__day + subq_17.metric_time__day AS metric_time__day , subq_16.listing AS listing , subq_16.bookers AS bookers - FROM ***************************.mf_time_spine subq_18 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_17 INNER JOIN ( -- Constrain Output with WHERE SELECT @@ -35,9 +42,9 @@ FROM ( ) subq_16 ON ( - subq_16.metric_time__day <= subq_18.ds + subq_16.metric_time__day <= subq_17.metric_time__day ) AND ( - subq_16.metric_time__day > subq_18.ds - MAKE_INTERVAL(days => 2) + subq_16.metric_time__day > subq_17.metric_time__day - MAKE_INTERVAL(days => 2) ) ) subq_20 LEFT OUTER JOIN diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index 50cdc52ebe..804aa456d5 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -25,8 +25,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_12.ds AS metric_time__day + DATE_TRUNC('day', subq_12.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_12 + GROUP BY + DATE_TRUNC('day', subq_12.ds) ) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures @@ -433,8 +435,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_30.ds AS metric_time__day + DATE_TRUNC('day', subq_30.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_30 + GROUP BY + DATE_TRUNC('day', subq_30.ds) ) subq_29 LEFT OUTER JOIN ( -- Aggregate Measures @@ -581,8 +585,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_18.ds AS metric_time__day + DATE_TRUNC('day', subq_18.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', subq_18.ds) ) subq_17 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql index 5fcdf34b3a..c46f40ebd4 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql @@ -19,10 +19,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_46.ds AS metric_time__day + subq_45.metric_time__day AS metric_time__day , subq_44.listing__country_latest AS listing__country_latest , subq_44.bookings AS bookings - FROM ***************************.mf_time_spine subq_46 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_46 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_45 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] @@ -60,7 +67,7 @@ FROM ( , listings_latest_src_28000.country ) subq_44 ON - subq_46.ds = subq_44.metric_time__day + subq_45.metric_time__day = subq_44.metric_time__day ) subq_47 ) subq_48 FULL OUTER JOIN ( @@ -72,10 +79,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_64.ds AS metric_time__day + subq_63.metric_time__day AS metric_time__day , subq_62.listing__country_latest AS listing__country_latest , subq_62.bookings AS bookings - FROM ***************************.mf_time_spine subq_64 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_64 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_63 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -96,11 +110,18 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_52.ds AS metric_time__day + subq_51.metric_time__day AS metric_time__day , subq_50.listing AS listing , subq_50.booking__is_instant AS booking__is_instant , subq_50.bookings AS bookings - FROM ***************************.mf_time_spine subq_52 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_52 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_51 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -112,7 +133,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_50 ON - subq_52.ds - MAKE_INTERVAL(days => 14) = subq_50.metric_time__day + subq_51.metric_time__day - MAKE_INTERVAL(days => 14) = subq_50.metric_time__day ) subq_54 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 @@ -125,7 +146,7 @@ FROM ( , listing__country_latest ) subq_62 ON - subq_64.ds = subq_62.metric_time__day + subq_63.metric_time__day = subq_62.metric_time__day ) subq_65 ) subq_66 ON diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_offset_metric_with_query_time_filters__plan0.sql index bb2bedb198..f243fc554f 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_offset_metric_with_query_time_filters__plan0.sql @@ -554,8 +554,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_15.ds AS metric_time__day + DATE_TRUNC('day', subq_15.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', subq_15.ds) ) subq_14 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_offset_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_offset_metric_with_query_time_filters__plan0_optimized.sql index 5c4d5d69cd..fac26a0447 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_offset_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_offset_metric_with_query_time_filters__plan0_optimized.sql @@ -68,11 +68,18 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_43.ds AS metric_time__day + subq_42.metric_time__day AS metric_time__day , subq_41.listing AS listing , subq_41.booking__is_instant AS booking__is_instant , subq_41.bookings AS bookings - FROM ***************************.mf_time_spine subq_43 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_43 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_42 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -84,7 +91,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_41 ON - subq_43.ds - MAKE_INTERVAL(days => 14) = subq_41.metric_time__day + subq_42.metric_time__day - MAKE_INTERVAL(days => 14) = subq_41.metric_time__day ) subq_45 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql index 00f2cc5ddb..ee0d39ba56 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql @@ -18,8 +18,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql index 8892599ad9..c97b53e629 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql @@ -7,10 +7,17 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , subq_13.booking__is_instant AS booking__is_instant , subq_13.bookings AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -34,6 +41,6 @@ FROM ( , booking__is_instant ) subq_13 ON - subq_15.ds = subq_13.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day ) subq_16 WHERE booking__is_instant diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_query_time_filters__plan0.sql index ed75cd86b6..23be0ff7a4 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_query_time_filters__plan0.sql @@ -148,8 +148,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql index a055d447cb..4f2e13c625 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql @@ -11,10 +11,17 @@ FROM ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_18.ds AS metric_time__day + subq_17.metric_time__day AS metric_time__day , subq_16.listing AS listing , subq_16.bookers AS bookers - FROM ***************************.mf_time_spine subq_18 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_17 INNER JOIN ( -- Constrain Output with WHERE SELECT @@ -35,9 +42,9 @@ FROM ( ) subq_16 ON ( - subq_16.metric_time__day <= subq_18.ds + subq_16.metric_time__day <= subq_17.metric_time__day ) AND ( - subq_16.metric_time__day > DATEADD(day, -2, subq_18.ds) + subq_16.metric_time__day > DATEADD(day, -2, subq_17.metric_time__day) ) ) subq_20 LEFT OUTER JOIN diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index ddff072fa4..f11f2a0311 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -25,8 +25,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_12.ds AS metric_time__day + DATE_TRUNC('day', subq_12.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_12 + GROUP BY + DATE_TRUNC('day', subq_12.ds) ) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures @@ -433,8 +435,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_30.ds AS metric_time__day + DATE_TRUNC('day', subq_30.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_30 + GROUP BY + DATE_TRUNC('day', subq_30.ds) ) subq_29 LEFT OUTER JOIN ( -- Aggregate Measures @@ -581,8 +585,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_18.ds AS metric_time__day + DATE_TRUNC('day', subq_18.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', subq_18.ds) ) subq_17 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql index fa9dd7b4cb..e85d308155 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql @@ -19,10 +19,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_46.ds AS metric_time__day + subq_45.metric_time__day AS metric_time__day , subq_44.listing__country_latest AS listing__country_latest , subq_44.bookings AS bookings - FROM ***************************.mf_time_spine subq_46 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_46 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_45 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] @@ -60,7 +67,7 @@ FROM ( , listings_latest_src_28000.country ) subq_44 ON - subq_46.ds = subq_44.metric_time__day + subq_45.metric_time__day = subq_44.metric_time__day ) subq_47 ) subq_48 FULL OUTER JOIN ( @@ -72,10 +79,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_64.ds AS metric_time__day + subq_63.metric_time__day AS metric_time__day , subq_62.listing__country_latest AS listing__country_latest , subq_62.bookings AS bookings - FROM ***************************.mf_time_spine subq_64 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_64 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_63 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -96,11 +110,18 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_52.ds AS metric_time__day + subq_51.metric_time__day AS metric_time__day , subq_50.listing AS listing , subq_50.booking__is_instant AS booking__is_instant , subq_50.bookings AS bookings - FROM ***************************.mf_time_spine subq_52 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_52 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_51 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -112,7 +133,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_50 ON - DATEADD(day, -14, subq_52.ds) = subq_50.metric_time__day + DATEADD(day, -14, subq_51.metric_time__day) = subq_50.metric_time__day ) subq_54 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 @@ -125,7 +146,7 @@ FROM ( , listing__country_latest ) subq_62 ON - subq_64.ds = subq_62.metric_time__day + subq_63.metric_time__day = subq_62.metric_time__day ) subq_65 ) subq_66 ON diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_offset_metric_with_query_time_filters__plan0.sql index 9ddee043d2..bc9e362587 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_offset_metric_with_query_time_filters__plan0.sql @@ -554,8 +554,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_15.ds AS metric_time__day + DATE_TRUNC('day', subq_15.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', subq_15.ds) ) subq_14 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_offset_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_offset_metric_with_query_time_filters__plan0_optimized.sql index 1f66c755da..2046094e5b 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_offset_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_offset_metric_with_query_time_filters__plan0_optimized.sql @@ -68,11 +68,18 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_43.ds AS metric_time__day + subq_42.metric_time__day AS metric_time__day , subq_41.listing AS listing , subq_41.booking__is_instant AS booking__is_instant , subq_41.bookings AS bookings - FROM ***************************.mf_time_spine subq_43 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_43 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_42 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -84,7 +91,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_41 ON - DATEADD(day, -14, subq_43.ds) = subq_41.metric_time__day + DATEADD(day, -14, subq_42.metric_time__day) = subq_41.metric_time__day ) subq_45 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql index 97481222b4..e73d568ca3 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql @@ -18,8 +18,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql index 8892599ad9..c97b53e629 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql @@ -7,10 +7,17 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , subq_13.booking__is_instant AS booking__is_instant , subq_13.bookings AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -34,6 +41,6 @@ FROM ( , booking__is_instant ) subq_13 ON - subq_15.ds = subq_13.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day ) subq_16 WHERE booking__is_instant diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_query_time_filters__plan0.sql index b5836aa84e..b680673c2c 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_query_time_filters__plan0.sql @@ -148,8 +148,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql index a055d447cb..4f2e13c625 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql @@ -11,10 +11,17 @@ FROM ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_18.ds AS metric_time__day + subq_17.metric_time__day AS metric_time__day , subq_16.listing AS listing , subq_16.bookers AS bookers - FROM ***************************.mf_time_spine subq_18 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_17 INNER JOIN ( -- Constrain Output with WHERE SELECT @@ -35,9 +42,9 @@ FROM ( ) subq_16 ON ( - subq_16.metric_time__day <= subq_18.ds + subq_16.metric_time__day <= subq_17.metric_time__day ) AND ( - subq_16.metric_time__day > DATEADD(day, -2, subq_18.ds) + subq_16.metric_time__day > DATEADD(day, -2, subq_17.metric_time__day) ) ) subq_20 LEFT OUTER JOIN diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index 2abe1d63f8..5aa52aaabe 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -25,8 +25,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_12.ds AS metric_time__day + DATE_TRUNC('day', subq_12.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_12 + GROUP BY + DATE_TRUNC('day', subq_12.ds) ) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures @@ -433,8 +435,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_30.ds AS metric_time__day + DATE_TRUNC('day', subq_30.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_30 + GROUP BY + DATE_TRUNC('day', subq_30.ds) ) subq_29 LEFT OUTER JOIN ( -- Aggregate Measures @@ -581,8 +585,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_18.ds AS metric_time__day + DATE_TRUNC('day', subq_18.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', subq_18.ds) ) subq_17 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql index fa9dd7b4cb..e85d308155 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql @@ -19,10 +19,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_46.ds AS metric_time__day + subq_45.metric_time__day AS metric_time__day , subq_44.listing__country_latest AS listing__country_latest , subq_44.bookings AS bookings - FROM ***************************.mf_time_spine subq_46 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_46 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_45 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] @@ -60,7 +67,7 @@ FROM ( , listings_latest_src_28000.country ) subq_44 ON - subq_46.ds = subq_44.metric_time__day + subq_45.metric_time__day = subq_44.metric_time__day ) subq_47 ) subq_48 FULL OUTER JOIN ( @@ -72,10 +79,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_64.ds AS metric_time__day + subq_63.metric_time__day AS metric_time__day , subq_62.listing__country_latest AS listing__country_latest , subq_62.bookings AS bookings - FROM ***************************.mf_time_spine subq_64 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_64 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_63 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -96,11 +110,18 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_52.ds AS metric_time__day + subq_51.metric_time__day AS metric_time__day , subq_50.listing AS listing , subq_50.booking__is_instant AS booking__is_instant , subq_50.bookings AS bookings - FROM ***************************.mf_time_spine subq_52 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_52 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_51 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -112,7 +133,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_50 ON - DATEADD(day, -14, subq_52.ds) = subq_50.metric_time__day + DATEADD(day, -14, subq_51.metric_time__day) = subq_50.metric_time__day ) subq_54 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 @@ -125,7 +146,7 @@ FROM ( , listing__country_latest ) subq_62 ON - subq_64.ds = subq_62.metric_time__day + subq_63.metric_time__day = subq_62.metric_time__day ) subq_65 ) subq_66 ON diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0.sql index 50abb77a30..d36be221aa 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0.sql @@ -554,8 +554,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_15.ds AS metric_time__day + DATE_TRUNC('day', subq_15.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', subq_15.ds) ) subq_14 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0_optimized.sql index 1f66c755da..2046094e5b 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_offset_metric_with_query_time_filters__plan0_optimized.sql @@ -68,11 +68,18 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_43.ds AS metric_time__day + subq_42.metric_time__day AS metric_time__day , subq_41.listing AS listing , subq_41.booking__is_instant AS booking__is_instant , subq_41.bookings AS bookings - FROM ***************************.mf_time_spine subq_43 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_43 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_42 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -84,7 +91,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_41 ON - DATEADD(day, -14, subq_43.ds) = subq_41.metric_time__day + DATEADD(day, -14, subq_42.metric_time__day) = subq_41.metric_time__day ) subq_45 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql index 39bd6a81fe..077d3599c5 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql @@ -18,8 +18,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql index 8892599ad9..c97b53e629 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql @@ -7,10 +7,17 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , subq_13.booking__is_instant AS booking__is_instant , subq_13.bookings AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -34,6 +41,6 @@ FROM ( , booking__is_instant ) subq_13 ON - subq_15.ds = subq_13.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day ) subq_16 WHERE booking__is_instant diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_query_time_filters__plan0.sql index 84395ca4b1..75511c89a3 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_query_time_filters__plan0.sql @@ -148,8 +148,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_3.ds AS metric_time__day + DATE_TRUNC('day', subq_3.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_3 + GROUP BY + DATE_TRUNC('day', subq_3.ds) ) subq_2 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql index 491a5cd358..a1c5838de3 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_cumulative_metric_with_query_time_filters__plan0_optimized.sql @@ -11,10 +11,17 @@ FROM ( -- Join Self Over Time Range -- Pass Only Elements: ['bookers', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_18.ds AS metric_time__day + subq_17.metric_time__day AS metric_time__day , subq_16.listing AS listing , subq_16.bookers AS bookers - FROM ***************************.mf_time_spine subq_18 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_17 INNER JOIN ( -- Constrain Output with WHERE SELECT @@ -35,9 +42,9 @@ FROM ( ) subq_16 ON ( - subq_16.metric_time__day <= subq_18.ds + subq_16.metric_time__day <= subq_17.metric_time__day ) AND ( - subq_16.metric_time__day > DATE_ADD('day', -2, subq_18.ds) + subq_16.metric_time__day > DATE_ADD('day', -2, subq_17.metric_time__day) ) ) subq_20 LEFT OUTER JOIN diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index b5ca222b03..244fba52c8 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -25,8 +25,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_12.ds AS metric_time__day + DATE_TRUNC('day', subq_12.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_12 + GROUP BY + DATE_TRUNC('day', subq_12.ds) ) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures @@ -433,8 +435,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_30.ds AS metric_time__day + DATE_TRUNC('day', subq_30.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_30 + GROUP BY + DATE_TRUNC('day', subq_30.ds) ) subq_29 LEFT OUTER JOIN ( -- Aggregate Measures @@ -581,8 +585,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_18.ds AS metric_time__day + DATE_TRUNC('day', subq_18.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_18 + GROUP BY + DATE_TRUNC('day', subq_18.ds) ) subq_17 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql index 928108e863..4a0019da27 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0_optimized.sql @@ -19,10 +19,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_46.ds AS metric_time__day + subq_45.metric_time__day AS metric_time__day , subq_44.listing__country_latest AS listing__country_latest , subq_44.bookings AS bookings - FROM ***************************.mf_time_spine subq_46 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_46 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_45 LEFT OUTER JOIN ( -- Join Standard Outputs -- Pass Only Elements: ['bookings', 'listing__country_latest', 'booking__is_instant', 'metric_time__day'] @@ -60,7 +67,7 @@ FROM ( , listings_latest_src_28000.country ) subq_44 ON - subq_46.ds = subq_44.metric_time__day + subq_45.metric_time__day = subq_44.metric_time__day ) subq_47 ) subq_48 FULL OUTER JOIN ( @@ -72,10 +79,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_64.ds AS metric_time__day + subq_63.metric_time__day AS metric_time__day , subq_62.listing__country_latest AS listing__country_latest , subq_62.bookings AS bookings - FROM ***************************.mf_time_spine subq_64 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_64 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_63 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'listing__country_latest', 'metric_time__day'] @@ -96,11 +110,18 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_52.ds AS metric_time__day + subq_51.metric_time__day AS metric_time__day , subq_50.listing AS listing , subq_50.booking__is_instant AS booking__is_instant , subq_50.bookings AS bookings - FROM ***************************.mf_time_spine subq_52 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_52 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_51 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -112,7 +133,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_50 ON - DATE_ADD('day', -14, subq_52.ds) = subq_50.metric_time__day + DATE_ADD('day', -14, subq_51.metric_time__day) = subq_50.metric_time__day ) subq_54 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 @@ -125,7 +146,7 @@ FROM ( , listing__country_latest ) subq_62 ON - subq_64.ds = subq_62.metric_time__day + subq_63.metric_time__day = subq_62.metric_time__day ) subq_65 ) subq_66 ON diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_offset_metric_with_query_time_filters__plan0.sql index 2444e2528e..bc89fec508 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_offset_metric_with_query_time_filters__plan0.sql @@ -554,8 +554,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_15.ds AS metric_time__day + DATE_TRUNC('day', subq_15.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', subq_15.ds) ) subq_14 INNER JOIN ( -- Metric Time Dimension 'ds' diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_offset_metric_with_query_time_filters__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_offset_metric_with_query_time_filters__plan0_optimized.sql index 0353ef9ebd..ce361a4234 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_offset_metric_with_query_time_filters__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_offset_metric_with_query_time_filters__plan0_optimized.sql @@ -68,11 +68,18 @@ FROM ( -- Join to Time Spine Dataset -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day', 'listing'] SELECT - subq_43.ds AS metric_time__day + subq_42.metric_time__day AS metric_time__day , subq_41.listing AS listing , subq_41.booking__is_instant AS booking__is_instant , subq_41.bookings AS bookings - FROM ***************************.mf_time_spine subq_43 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_43 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_42 INNER JOIN ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' @@ -84,7 +91,7 @@ FROM ( FROM ***************************.fct_bookings bookings_source_src_28000 ) subq_41 ON - DATE_ADD('day', -14, subq_43.ds) = subq_41.metric_time__day + DATE_ADD('day', -14, subq_42.metric_time__day) = subq_41.metric_time__day ) subq_45 LEFT OUTER JOIN ***************************.dim_listings_latest listings_latest_src_28000 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql index f16d7296b5..beaabb3869 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_pushdown_filter_application__plan0.sql @@ -18,8 +18,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql index 8892599ad9..c97b53e629 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_pushdown_filter_application__plan0_optimized.sql @@ -7,10 +7,17 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , subq_13.booking__is_instant AS booking__is_instant , subq_13.bookings AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -34,6 +41,6 @@ FROM ( , booking__is_instant ) subq_13 ON - subq_15.ds = subq_13.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day ) subq_16 WHERE booking__is_instant diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0.sql index 6dd6280953..a2de4603cd 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0.sql @@ -15,9 +15,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATETIME_TRUNC(subq_6.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + metric_time__day ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql index b0ed4836c9..1b83e60363 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql @@ -11,9 +11,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATETIME_TRUNC(ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_15 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + metric_time__day ) subq_14 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine__plan0.sql index 91e10c5ccd..ba97632b21 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATETIME_TRUNC(subq_5.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + metric_time__day ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine__plan0_optimized.sql index 3da2e2fa5f..975e83f9e3 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine__plan0_optimized.sql @@ -1,9 +1,16 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ds AS metric_time__day + subq_11.metric_time__day AS metric_time__day , subq_10.bookings AS bookings_join_to_time_spine -FROM ***************************.mf_time_spine subq_12 +FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + GROUP BY + metric_time__day +) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -22,4 +29,4 @@ LEFT OUTER JOIN ( metric_time__day ) subq_10 ON - subq_12.ds = subq_10.metric_time__day + subq_11.metric_time__day = subq_10.metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0.sql index 75603754c5..4a24086470 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day + DATETIME_TRUNC(subq_7.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_7 + GROUP BY + metric_time__day ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql index ecb1ad0528..9fbfaaeab4 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql @@ -5,9 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_16.ds AS metric_time__day + subq_15.metric_time__day AS metric_time__day , subq_14.bookings AS bookings - FROM ***************************.mf_time_spine subq_16 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + GROUP BY + metric_time__day + ) subq_15 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -30,5 +37,5 @@ FROM ( metric_time__day ) subq_14 ON - subq_16.ds = subq_14.metric_time__day + subq_15.metric_time__day = subq_14.metric_time__day ) subq_17 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0.sql index 7945e559e4..d3c782e61e 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0.sql @@ -18,8 +18,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATETIME_TRUNC(subq_6.ds, day) AS metric_time__day FROM ***************************.mf_time_spine subq_6 + GROUP BY + metric_time__day ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql index 41be8cd7d5..3eecf6fbd2 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/BigQuery/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql @@ -12,10 +12,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , subq_13.booking__is_instant AS booking__is_instant , subq_13.bookings AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATETIME_TRUNC(ds, day) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + metric_time__day + ) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -39,7 +46,7 @@ FROM ( , booking__is_instant ) subq_13 ON - subq_15.ds = subq_13.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day ) subq_16 WHERE booking__is_instant ) subq_17 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0.sql index 971ce1cff6..ef2ae11773 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0.sql @@ -15,9 +15,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql index fb7e2c593f..6819a9d433 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql @@ -11,9 +11,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_15 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + DATE_TRUNC('day', ds) ) subq_14 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine__plan0.sql index dfd4b38666..4c4409fe7d 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine__plan0_optimized.sql index 03e7c6a8a1..4c2b5b9b75 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine__plan0_optimized.sql @@ -1,9 +1,16 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ds AS metric_time__day + subq_11.metric_time__day AS metric_time__day , subq_10.bookings AS bookings_join_to_time_spine -FROM ***************************.mf_time_spine subq_12 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + GROUP BY + DATE_TRUNC('day', ds) +) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -22,4 +29,4 @@ LEFT OUTER JOIN ( metric_time__day ) subq_10 ON - subq_12.ds = subq_10.metric_time__day + subq_11.metric_time__day = subq_10.metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0.sql index 10d71d6f54..f40252e453 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day + DATE_TRUNC('day', subq_7.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_7 + GROUP BY + DATE_TRUNC('day', subq_7.ds) ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql index 9a4f540d4c..b4a7b8308d 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql @@ -5,9 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_16.ds AS metric_time__day + subq_15.metric_time__day AS metric_time__day , subq_14.bookings AS bookings - FROM ***************************.mf_time_spine subq_16 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_15 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -30,5 +37,5 @@ FROM ( metric_time__day ) subq_14 ON - subq_16.ds = subq_14.metric_time__day + subq_15.metric_time__day = subq_14.metric_time__day ) subq_17 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0.sql index d60f9f75b1..550b4c7fea 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0.sql @@ -18,8 +18,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql index 19f81cdd9b..8c2109274c 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Databricks/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql @@ -12,10 +12,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , subq_13.booking__is_instant AS booking__is_instant , subq_13.bookings AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -39,7 +46,7 @@ FROM ( , booking__is_instant ) subq_13 ON - subq_15.ds = subq_13.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day ) subq_16 WHERE booking__is_instant ) subq_17 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0.sql index a7fd42dafc..dd8433e339 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0.sql @@ -15,9 +15,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql index fb7e2c593f..6819a9d433 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql @@ -11,9 +11,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_15 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + DATE_TRUNC('day', ds) ) subq_14 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine__plan0.sql index 0ea077947e..ede1b4d1c9 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine__plan0_optimized.sql index 03e7c6a8a1..4c2b5b9b75 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine__plan0_optimized.sql @@ -1,9 +1,16 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ds AS metric_time__day + subq_11.metric_time__day AS metric_time__day , subq_10.bookings AS bookings_join_to_time_spine -FROM ***************************.mf_time_spine subq_12 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + GROUP BY + DATE_TRUNC('day', ds) +) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -22,4 +29,4 @@ LEFT OUTER JOIN ( metric_time__day ) subq_10 ON - subq_12.ds = subq_10.metric_time__day + subq_11.metric_time__day = subq_10.metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0.sql index a39da38b06..3e8412226d 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day + DATE_TRUNC('day', subq_7.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_7 + GROUP BY + DATE_TRUNC('day', subq_7.ds) ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql index 9a4f540d4c..b4a7b8308d 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql @@ -5,9 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_16.ds AS metric_time__day + subq_15.metric_time__day AS metric_time__day , subq_14.bookings AS bookings - FROM ***************************.mf_time_spine subq_16 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_15 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -30,5 +37,5 @@ FROM ( metric_time__day ) subq_14 ON - subq_16.ds = subq_14.metric_time__day + subq_15.metric_time__day = subq_14.metric_time__day ) subq_17 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0.sql index ed0bc69197..411a5f04b2 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0.sql @@ -18,8 +18,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql index 19f81cdd9b..8c2109274c 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Postgres/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql @@ -12,10 +12,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , subq_13.booking__is_instant AS booking__is_instant , subq_13.bookings AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -39,7 +46,7 @@ FROM ( , booking__is_instant ) subq_13 ON - subq_15.ds = subq_13.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day ) subq_16 WHERE booking__is_instant ) subq_17 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0.sql index 0e3b950240..50c2ae03c9 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0.sql @@ -15,9 +15,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql index fb7e2c593f..6819a9d433 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql @@ -11,9 +11,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_15 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + DATE_TRUNC('day', ds) ) subq_14 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine__plan0.sql index c326cd2894..1a7bd45c50 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine__plan0_optimized.sql index 03e7c6a8a1..4c2b5b9b75 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine__plan0_optimized.sql @@ -1,9 +1,16 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ds AS metric_time__day + subq_11.metric_time__day AS metric_time__day , subq_10.bookings AS bookings_join_to_time_spine -FROM ***************************.mf_time_spine subq_12 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + GROUP BY + DATE_TRUNC('day', ds) +) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -22,4 +29,4 @@ LEFT OUTER JOIN ( metric_time__day ) subq_10 ON - subq_12.ds = subq_10.metric_time__day + subq_11.metric_time__day = subq_10.metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0.sql index fbbca501a8..d6a9b4503b 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day + DATE_TRUNC('day', subq_7.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_7 + GROUP BY + DATE_TRUNC('day', subq_7.ds) ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql index 9a4f540d4c..b4a7b8308d 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql @@ -5,9 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_16.ds AS metric_time__day + subq_15.metric_time__day AS metric_time__day , subq_14.bookings AS bookings - FROM ***************************.mf_time_spine subq_16 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_15 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -30,5 +37,5 @@ FROM ( metric_time__day ) subq_14 ON - subq_16.ds = subq_14.metric_time__day + subq_15.metric_time__day = subq_14.metric_time__day ) subq_17 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0.sql index 53e30fb806..fa2a9f7ad5 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0.sql @@ -18,8 +18,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql index 19f81cdd9b..8c2109274c 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Redshift/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql @@ -12,10 +12,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , subq_13.booking__is_instant AS booking__is_instant , subq_13.bookings AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -39,7 +46,7 @@ FROM ( , booking__is_instant ) subq_13 ON - subq_15.ds = subq_13.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day ) subq_16 WHERE booking__is_instant ) subq_17 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0.sql index fd9ed3dd3b..f98329cec8 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0.sql @@ -15,9 +15,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql index fb7e2c593f..6819a9d433 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql @@ -11,9 +11,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_15 WHERE ds BETWEEN '2020-01-03' AND '2020-01-05' + GROUP BY + DATE_TRUNC('day', ds) ) subq_14 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine__plan0.sql index f7057f7312..9dabdaa974 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine__plan0_optimized.sql index 03e7c6a8a1..4c2b5b9b75 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine__plan0_optimized.sql @@ -1,9 +1,16 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ds AS metric_time__day + subq_11.metric_time__day AS metric_time__day , subq_10.bookings AS bookings_join_to_time_spine -FROM ***************************.mf_time_spine subq_12 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + GROUP BY + DATE_TRUNC('day', ds) +) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -22,4 +29,4 @@ LEFT OUTER JOIN ( metric_time__day ) subq_10 ON - subq_12.ds = subq_10.metric_time__day + subq_11.metric_time__day = subq_10.metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0.sql index 1841f75d94..6351e36b01 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day + DATE_TRUNC('day', subq_7.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_7 + GROUP BY + DATE_TRUNC('day', subq_7.ds) ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql index 9a4f540d4c..b4a7b8308d 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql @@ -5,9 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_16.ds AS metric_time__day + subq_15.metric_time__day AS metric_time__day , subq_14.bookings AS bookings - FROM ***************************.mf_time_spine subq_16 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_15 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -30,5 +37,5 @@ FROM ( metric_time__day ) subq_14 ON - subq_16.ds = subq_14.metric_time__day + subq_15.metric_time__day = subq_14.metric_time__day ) subq_17 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0.sql index 06ba1452be..92cea0f7ec 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0.sql @@ -18,8 +18,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql index 19f81cdd9b..8c2109274c 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Snowflake/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql @@ -12,10 +12,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , subq_13.booking__is_instant AS booking__is_instant , subq_13.bookings AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -39,7 +46,7 @@ FROM ( , booking__is_instant ) subq_13 ON - subq_15.ds = subq_13.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day ) subq_16 WHERE booking__is_instant ) subq_17 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0.sql index 49f3c834a9..3d6ffbc800 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0.sql @@ -15,9 +15,11 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 WHERE subq_6.ds BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql index bfc306b207..f2904deccd 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_join_to_time_spine_with_queried_time_constraint__plan0_optimized.sql @@ -11,9 +11,11 @@ FROM ( FROM ( -- Time Spine SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day FROM ***************************.mf_time_spine subq_15 WHERE ds BETWEEN timestamp '2020-01-03' AND timestamp '2020-01-05' + GROUP BY + DATE_TRUNC('day', ds) ) subq_14 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine__plan0.sql index 138a4b4df5..4f6016e204 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_5.ds AS metric_time__day + DATE_TRUNC('day', subq_5.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_5 + GROUP BY + DATE_TRUNC('day', subq_5.ds) ) subq_4 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine__plan0_optimized.sql index 03e7c6a8a1..4c2b5b9b75 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine__plan0_optimized.sql @@ -1,9 +1,16 @@ -- Join to Time Spine Dataset -- Compute Metrics via Expressions SELECT - subq_12.ds AS metric_time__day + subq_11.metric_time__day AS metric_time__day , subq_10.bookings AS bookings_join_to_time_spine -FROM ***************************.mf_time_spine subq_12 +FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_12 + GROUP BY + DATE_TRUNC('day', ds) +) subq_11 LEFT OUTER JOIN ( -- Aggregate Measures SELECT @@ -22,4 +29,4 @@ LEFT OUTER JOIN ( metric_time__day ) subq_10 ON - subq_12.ds = subq_10.metric_time__day + subq_11.metric_time__day = subq_10.metric_time__day diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0.sql index 6c43edefe6..1c6ec49302 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0.sql @@ -10,8 +10,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_7.ds AS metric_time__day + DATE_TRUNC('day', subq_7.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_7 + GROUP BY + DATE_TRUNC('day', subq_7.ds) ) subq_6 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql index 9a4f540d4c..b4a7b8308d 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_filter__plan0_optimized.sql @@ -5,9 +5,16 @@ SELECT FROM ( -- Join to Time Spine Dataset SELECT - subq_16.ds AS metric_time__day + subq_15.metric_time__day AS metric_time__day , subq_14.bookings AS bookings - FROM ***************************.mf_time_spine subq_16 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_16 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_15 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -30,5 +37,5 @@ FROM ( metric_time__day ) subq_14 ON - subq_16.ds = subq_14.metric_time__day + subq_15.metric_time__day = subq_14.metric_time__day ) subq_17 diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0.sql index 7fe5de84a9..884cb7f11d 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0.sql @@ -18,8 +18,10 @@ FROM ( FROM ( -- Time Spine SELECT - subq_6.ds AS metric_time__day + DATE_TRUNC('day', subq_6.ds) AS metric_time__day FROM ***************************.mf_time_spine subq_6 + GROUP BY + DATE_TRUNC('day', subq_6.ds) ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql index 19f81cdd9b..8c2109274c 100644 --- a/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_time_spine_join_rendering.py/SqlQueryPlan/Trino/test_simple_join_to_time_spine_with_queried_filter__plan0_optimized.sql @@ -12,10 +12,17 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_15.ds AS metric_time__day + subq_14.metric_time__day AS metric_time__day , subq_13.booking__is_instant AS booking__is_instant , subq_13.bookings AS bookings - FROM ***************************.mf_time_spine subq_15 + FROM ( + -- Time Spine + SELECT + DATE_TRUNC('day', ds) AS metric_time__day + FROM ***************************.mf_time_spine subq_15 + GROUP BY + DATE_TRUNC('day', ds) + ) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE -- Pass Only Elements: ['bookings', 'booking__is_instant', 'metric_time__day'] @@ -39,7 +46,7 @@ FROM ( , booking__is_instant ) subq_13 ON - subq_15.ds = subq_13.metric_time__day + subq_14.metric_time__day = subq_13.metric_time__day ) subq_16 WHERE booking__is_instant ) subq_17