From b675d515c2c4cbaa99ee5103938e04229b9c2855 Mon Sep 17 00:00:00 2001 From: tlento Date: Tue, 26 Sep 2023 11:26:54 -0700 Subject: [PATCH 1/2] Move semantic model time dimension conversion into its own method The time dimension conversion logic inside of our semantic model to data set converter class has expanded to the point where it's difficult to reason through where or how to best make changes. In order to at least keep added layers of logic isolated to the specific task of converting time dimensions, this commit moves that logic into a separate private method. --- metricflow/dataset/convert_semantic_model.py | 124 +++++++++++-------- 1 file changed, 73 insertions(+), 51 deletions(-) diff --git a/metricflow/dataset/convert_semantic_model.py b/metricflow/dataset/convert_semantic_model.py index 296168df21..c2b14936d2 100644 --- a/metricflow/dataset/convert_semantic_model.py +++ b/metricflow/dataset/convert_semantic_model.py @@ -241,73 +241,95 @@ def _convert_dimensions( column_alias=dimension_instance.associated_column.column_name, ) ) - elif dimension.type == DimensionType.TIME: - defined_time_granularity = TimeGranularity.DAY - if dimension.type_params and dimension.type_params.time_granularity: - defined_time_granularity = dimension.type_params.time_granularity + derived_time_dimension_instances, time_select_columns = self._convert_time_dimension( + dimension_select_expr=dimension_select_expr, + dimension=dimension, + semantic_model_name=semantic_model_name, + entity_links=entity_links, + ) + time_dimension_instances += derived_time_dimension_instances + select_columns += time_select_columns + else: + assert False, f"Unhandled dimension type: {dimension.type}" + + return DimensionConversionResult( + dimension_instances=dimension_instances, + time_dimension_instances=time_dimension_instances, + select_columns=select_columns, + ) + + def _convert_time_dimension( + self, + dimension_select_expr: SqlExpressionNode, + dimension: Dimension, + semantic_model_name: str, + entity_links: Tuple[EntityReference, ...], + ) -> Tuple[List[TimeDimensionInstance], List[SqlSelectColumn]]: + """Converts Dimension objects with type TIME into the relevant DataSet columns. + + Time dimensions require special handling that includes adding additional instances + and select column statements for each granularity and date part + """ + time_dimension_instances: List[TimeDimensionInstance] = [] + select_columns: List[SqlSelectColumn] = [] + + defined_time_granularity = TimeGranularity.DAY + if dimension.type_params and dimension.type_params.time_granularity: + defined_time_granularity = dimension.type_params.time_granularity + + time_dimension_instance = self._create_time_dimension_instance( + semantic_model_name=semantic_model_name, + time_dimension=dimension, + entity_links=entity_links, + time_granularity=defined_time_granularity, + ) + time_dimension_instances.append(time_dimension_instance) + select_columns.append( + SqlSelectColumn( + expr=dimension_select_expr, + column_alias=time_dimension_instance.associated_column.column_name, + ) + ) + # Add time dimensions with a smaller granularity for ease in query resolution + for time_granularity in TimeGranularity: + if time_granularity.to_int() > defined_time_granularity.to_int(): time_dimension_instance = self._create_time_dimension_instance( semantic_model_name=semantic_model_name, time_dimension=dimension, entity_links=entity_links, - time_granularity=defined_time_granularity, + time_granularity=time_granularity, ) time_dimension_instances.append(time_dimension_instance) + select_columns.append( SqlSelectColumn( - expr=dimension_select_expr, + expr=SqlDateTruncExpression(time_granularity=time_granularity, arg=dimension_select_expr), column_alias=time_dimension_instance.associated_column.column_name, ) ) - # Add time dimensions with a smaller granularity for ease in query resolution - for time_granularity in TimeGranularity: - if time_granularity.to_int() > defined_time_granularity.to_int(): - time_dimension_instance = self._create_time_dimension_instance( - semantic_model_name=semantic_model_name, - time_dimension=dimension, - entity_links=entity_links, - time_granularity=time_granularity, - ) - time_dimension_instances.append(time_dimension_instance) - - select_columns.append( - SqlSelectColumn( - expr=SqlDateTruncExpression( - time_granularity=time_granularity, arg=dimension_select_expr - ), - column_alias=time_dimension_instance.associated_column.column_name, - ) - ) - - # Add all date part options for easy query resolution - for date_part in DatePart: - if date_part.to_int() >= defined_time_granularity.to_int(): - time_dimension_instance = self._create_time_dimension_instance( - semantic_model_name=semantic_model_name, - time_dimension=dimension, - entity_links=entity_links, - time_granularity=defined_time_granularity, - date_part=date_part, - ) - time_dimension_instances.append(time_dimension_instance) - - select_columns.append( - SqlSelectColumn( - expr=SqlExtractExpression(date_part=date_part, arg=dimension_select_expr), - column_alias=time_dimension_instance.associated_column.column_name, - ) - ) + # Add all date part options for easy query resolution + for date_part in DatePart: + if date_part.to_int() >= defined_time_granularity.to_int(): + time_dimension_instance = self._create_time_dimension_instance( + semantic_model_name=semantic_model_name, + time_dimension=dimension, + entity_links=entity_links, + time_granularity=defined_time_granularity, + date_part=date_part, + ) + time_dimension_instances.append(time_dimension_instance) - else: - assert False, f"Unhandled dimension type: {dimension.type}" + select_columns.append( + SqlSelectColumn( + expr=SqlExtractExpression(date_part=date_part, arg=dimension_select_expr), + column_alias=time_dimension_instance.associated_column.column_name, + ) + ) - return DimensionConversionResult( - dimension_instances=dimension_instances, - time_dimension_instances=time_dimension_instances, - select_columns=select_columns, - ) + return (time_dimension_instances, select_columns) def _create_entity_instances( self, From 6260b7a129b42aa78b266dec418b5a3e5d3eeb32 Mon Sep 17 00:00:00 2001 From: tlento Date: Wed, 4 Oct 2023 19:12:55 -0700 Subject: [PATCH 2/2] Update rendering to use date_trunc on base time dimension granularity MetricFlow's initial time dimension select statement rendering was built on the assumption that the granularity configred for a given time dimension would always match the granularity of the values stored. For example, if a time dimension was defined with granularity DAY, we assumed that the values in the warehouse would always correspond to daily granularity data, and would never be offset from a day boundary. This assumption is flawed for a variety of reasons - yearly or quarterly granularities might use different offset boundaries, users may misconfigure dimensions or allow offset values into the dataset which could be safely corrected, etc. This change updates our rendering to apply the date_trunc operation on the base time dimension column, just as we do for the other, coarser granularities. The one exception is for the base granularity column for validity window time dimensions, which must retain their underlying granularity in order to remain viable as validity window boundaries for any DAILY granularity contexts, as we do not support smaller than daily granularities at this time. Note this may cause queries with start and end time constraints to no longer trigger partition pruning, an issue which will be addressed in subsequent updates. --- .../unreleased/Fixes-20231005-124722.yaml | 7 + metricflow/dataset/convert_semantic_model.py | 22 +- ...st_convert_query_semantic_model__plan0.sql | 4 +- ...le_semantic_model_with_measures__plan0.sql | 8 +- ...semantic_model_without_measures__plan0.sql | 4 +- ...st_convert_query_semantic_model__plan0.sql | 4 +- ...le_semantic_model_with_measures__plan0.sql | 8 +- ...semantic_model_without_measures__plan0.sql | 4 +- ...st_convert_query_semantic_model__plan0.sql | 4 +- ...le_semantic_model_with_measures__plan0.sql | 8 +- ...semantic_model_without_measures__plan0.sql | 4 +- ...st_convert_query_semantic_model__plan0.sql | 4 +- ...le_semantic_model_with_measures__plan0.sql | 8 +- ...semantic_model_without_measures__plan0.sql | 4 +- ...st_convert_query_semantic_model__plan0.sql | 4 +- ...le_semantic_model_with_measures__plan0.sql | 8 +- ...semantic_model_without_measures__plan0.sql | 4 +- ...st_convert_query_semantic_model__plan0.sql | 4 +- ...le_semantic_model_with_measures__plan0.sql | 8 +- ...semantic_model_without_measures__plan0.sql | 4 +- .../test_build_metric_tasks__query0.sql | 2 +- .../test_build_metric_tasks__query0.sql | 2 +- .../test_build_metric_tasks__query0.sql | 2 +- .../test_build_metric_tasks__query0.sql | 2 +- .../test_build_metric_tasks__query0.sql | 2 +- .../test_build_metric_tasks__query0.sql | 2 +- .../test_combined_metrics_plan__ep_0.xml | 6 +- .../test_multihop_joined_plan__ep_0.xml | 72 +-- .../test_combined_metrics_plan__ep_0.xml | 8 +- .../test_multihop_joined_plan__ep_0.xml | 72 +-- .../test_combined_metrics_plan__ep_0.xml | 8 +- .../test_multihop_joined_plan__ep_0.xml | 72 +-- .../test_combined_metrics_plan__ep_0.xml | 8 +- .../test_multihop_joined_plan__ep_0.xml | 72 +-- .../test_combined_metrics_plan__ep_0.xml | 8 +- .../test_multihop_joined_plan__ep_0.xml | 72 +-- .../test_combined_metrics_plan__ep_0.xml | 8 +- .../test_multihop_joined_plan__ep_0.xml | 72 +-- .../test_common_semantic_model__plan0.sql | 24 +- ...common_semantic_model__plan0_optimized.sql | 4 +- .../test_compute_metrics_node__plan0.sql | 20 +- ...o_from_multiple_semantic_models__plan0.sql | 36 +- ...tiple_semantic_models__plan0_optimized.sql | 4 +- ...atio_from_single_semantic_model__plan0.sql | 20 +- ...ompute_metrics_node_simple_expr__plan0.sql | 20 +- .../test_constrain_time_range_node__plan0.sql | 12 +- ...train_time_range_node__plan0_optimized.sql | 6 +- .../test_cumulative_metric__plan0.sql | 4 +- ...cumulative_metric_grain_to_date__plan0.sql | 4 +- .../test_cumulative_metric_no_ds__plan0.sql | 4 +- ...est_cumulative_metric_no_window__plan0.sql | 4 +- ..._no_window_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- ...ive_metric_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- .../BigQuery/test_derived_metric__plan0.sql | 24 +- .../test_derived_metric__plan0_optimized.sql | 4 +- ...ved_metric_with_offset_to_grain__plan0.sql | 24 +- ..._with_offset_to_grain__plan0_optimized.sql | 4 +- ...offset_to_grain_and_granularity__plan0.sql | 24 +- ...grain_and_granularity__plan0_optimized.sql | 2 +- ...rived_metric_with_offset_window__plan0.sql | 24 +- ...ic_with_offset_window__plan0_optimized.sql | 4 +- ...h_offset_window_and_granularity__plan0.sql | 24 +- ...indow_and_granularity__plan0_optimized.sql | 2 +- ...fset_window_and_offset_to_grain__plan0.sql | 24 +- ...w_and_offset_to_grain__plan0_optimized.sql | 4 +- ...offset_to_grain_and_granularity__plan0.sql | 24 +- ...grain_and_granularity__plan0_optimized.sql | 4 +- ...erived_offset_cumulative_metric__plan0.sql | 12 +- ...set_cumulative_metric__plan0_optimized.sql | 4 +- ...et_metric_with_one_input_metric__plan0.sql | 12 +- ...with_one_input_metric__plan0_optimized.sql | 2 +- .../BigQuery/test_distinct_values__plan0.sql | 20 +- .../BigQuery/test_filter_node__plan0.sql | 12 +- ...lter_with_where_constraint_node__plan0.sql | 12 +- ...where_constraint_node__plan0_optimized.sql | 2 +- ...th_where_constraint_on_join_dim__plan0.sql | 20 +- .../test_join_to_scd_dimension__plan0.sql | 12 +- ...join_to_scd_dimension__plan0_optimized.sql | 2 +- ...spine_node_with_offset_to_grain__plan0.sql | 12 +- ..._with_offset_to_grain__plan0_optimized.sql | 2 +- ...e_spine_node_with_offset_window__plan0.sql | 12 +- ...de_with_offset_window__plan0_optimized.sql | 2 +- ..._time_spine_node_without_offset__plan0.sql | 12 +- ...e_node_without_offset__plan0_optimized.sql | 2 +- .../BigQuery/test_limit_rows__plan0.sql | 12 +- .../test_limit_rows__plan0_optimized.sql | 2 +- ...al_dimension_using_local_entity__plan0.sql | 8 +- .../test_measure_aggregation_node__plan0.sql | 12 +- .../test_measure_constraint__plan0.sql | 52 +-- ...st_measure_constraint__plan0_optimized.sql | 6 +- ..._constraint_with_reused_measure__plan0.sql | 24 +- ...t_with_reused_measure__plan0_optimized.sql | 4 +- ...aint_with_single_expr_and_alias__plan0.sql | 12 +- ...single_expr_and_alias__plan0_optimized.sql | 2 +- ..._multiple_sources_no_dimensions__plan0.sql | 20 +- ...multi_hop_through_scd_dimension__plan0.sql | 16 +- ...through_scd_dimension__plan0_optimized.sql | 2 +- ...test_multi_hop_to_scd_dimension__plan0.sql | 12 +- ..._hop_to_scd_dimension__plan0_optimized.sql | 2 +- .../BigQuery/test_multi_join_node__plan0.sql | 28 +- .../BigQuery/test_multihop_node__plan0.sql | 18 +- .../test_multihop_node__plan0_optimized.sql | 6 +- ..._multiple_metrics_no_dimensions__plan0.sql | 20 +- ...metrics_no_dimensions__plan0_optimized.sql | 4 +- .../test_nested_derived_metric__plan0.sql | 48 +- ...nested_derived_metric__plan0_optimized.sql | 8 +- ...st_offset_window_with_date_part__plan0.sql | 24 +- ...window_with_date_part__plan0_optimized.sql | 2 +- .../BigQuery/test_order_by_node__plan0.sql | 12 +- .../test_order_by_node__plan0_optimized.sql | 2 +- .../BigQuery/test_partitioned_join__plan0.sql | 20 +- ...test_partitioned_join__plan0_optimized.sql | 4 +- .../test_semi_additive_join_node__plan0.sql | 8 +- ...mi_additive_join_node__plan0_optimized.sql | 6 +- ...dditive_join_node_with_grouping__plan0.sql | 8 +- ...in_node_with_grouping__plan0_optimized.sql | 6 +- ...join_node_with_queried_group_by__plan0.sql | 8 +- ...with_queried_group_by__plan0_optimized.sql | 6 +- ...est_simple_query_with_date_part__plan0.sql | 12 +- ..._query_with_multiple_date_parts__plan0.sql | 12 +- .../BigQuery/test_single_join_node__plan0.sql | 20 +- .../BigQuery/test_source_node__plan0.sql | 12 +- .../test_source_node__plan0_optimized.sql | 12 +- .../test_common_semantic_model__plan0.sql | 24 +- ...common_semantic_model__plan0_optimized.sql | 6 +- .../test_compute_metrics_node__plan0.sql | 20 +- ...o_from_multiple_semantic_models__plan0.sql | 36 +- ...tiple_semantic_models__plan0_optimized.sql | 4 +- ...atio_from_single_semantic_model__plan0.sql | 20 +- ...ompute_metrics_node_simple_expr__plan0.sql | 20 +- .../test_constrain_time_range_node__plan0.sql | 12 +- ...train_time_range_node__plan0_optimized.sql | 6 +- .../test_cumulative_metric__plan0.sql | 4 +- ...cumulative_metric_grain_to_date__plan0.sql | 4 +- .../test_cumulative_metric_no_ds__plan0.sql | 4 +- ...est_cumulative_metric_no_window__plan0.sql | 4 +- ..._no_window_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- ...ive_metric_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- .../Databricks/test_derived_metric__plan0.sql | 24 +- .../test_derived_metric__plan0_optimized.sql | 4 +- ...ved_metric_with_offset_to_grain__plan0.sql | 24 +- ..._with_offset_to_grain__plan0_optimized.sql | 4 +- ...offset_to_grain_and_granularity__plan0.sql | 24 +- ...grain_and_granularity__plan0_optimized.sql | 2 +- ...rived_metric_with_offset_window__plan0.sql | 24 +- ...ic_with_offset_window__plan0_optimized.sql | 4 +- ...h_offset_window_and_granularity__plan0.sql | 24 +- ...indow_and_granularity__plan0_optimized.sql | 2 +- ...fset_window_and_offset_to_grain__plan0.sql | 24 +- ...w_and_offset_to_grain__plan0_optimized.sql | 4 +- ...offset_to_grain_and_granularity__plan0.sql | 24 +- ...grain_and_granularity__plan0_optimized.sql | 4 +- ...erived_offset_cumulative_metric__plan0.sql | 12 +- ...set_cumulative_metric__plan0_optimized.sql | 4 +- ...et_metric_with_one_input_metric__plan0.sql | 12 +- ...with_one_input_metric__plan0_optimized.sql | 2 +- .../test_distinct_values__plan0.sql | 20 +- .../Databricks/test_filter_node__plan0.sql | 12 +- ...lter_with_where_constraint_node__plan0.sql | 12 +- ...where_constraint_node__plan0_optimized.sql | 2 +- ...th_where_constraint_on_join_dim__plan0.sql | 20 +- .../test_join_to_scd_dimension__plan0.sql | 12 +- ...join_to_scd_dimension__plan0_optimized.sql | 2 +- ...spine_node_with_offset_to_grain__plan0.sql | 12 +- ..._with_offset_to_grain__plan0_optimized.sql | 4 +- ...e_spine_node_with_offset_window__plan0.sql | 12 +- ...de_with_offset_window__plan0_optimized.sql | 4 +- ..._time_spine_node_without_offset__plan0.sql | 12 +- ...e_node_without_offset__plan0_optimized.sql | 4 +- .../Databricks/test_limit_rows__plan0.sql | 12 +- .../test_limit_rows__plan0_optimized.sql | 2 +- ...al_dimension_using_local_entity__plan0.sql | 8 +- .../test_measure_aggregation_node__plan0.sql | 12 +- .../test_measure_constraint__plan0.sql | 52 +-- ...st_measure_constraint__plan0_optimized.sql | 8 +- ..._constraint_with_reused_measure__plan0.sql | 24 +- ...t_with_reused_measure__plan0_optimized.sql | 6 +- ...aint_with_single_expr_and_alias__plan0.sql | 12 +- ...single_expr_and_alias__plan0_optimized.sql | 2 +- ..._multiple_sources_no_dimensions__plan0.sql | 20 +- ...multi_hop_through_scd_dimension__plan0.sql | 16 +- ...through_scd_dimension__plan0_optimized.sql | 2 +- ...test_multi_hop_to_scd_dimension__plan0.sql | 12 +- ..._hop_to_scd_dimension__plan0_optimized.sql | 2 +- .../test_multi_join_node__plan0.sql | 28 +- .../Databricks/test_multihop_node__plan0.sql | 18 +- .../test_multihop_node__plan0_optimized.sql | 6 +- ..._multiple_metrics_no_dimensions__plan0.sql | 20 +- ...metrics_no_dimensions__plan0_optimized.sql | 4 +- .../test_nested_derived_metric__plan0.sql | 48 +- ...nested_derived_metric__plan0_optimized.sql | 8 +- ...st_offset_window_with_date_part__plan0.sql | 24 +- ...window_with_date_part__plan0_optimized.sql | 2 +- .../Databricks/test_order_by_node__plan0.sql | 12 +- .../test_order_by_node__plan0_optimized.sql | 2 +- .../test_partitioned_join__plan0.sql | 20 +- ...test_partitioned_join__plan0_optimized.sql | 4 +- .../test_semi_additive_join_node__plan0.sql | 8 +- ...mi_additive_join_node__plan0_optimized.sql | 6 +- ...dditive_join_node_with_grouping__plan0.sql | 8 +- ...in_node_with_grouping__plan0_optimized.sql | 6 +- ...join_node_with_queried_group_by__plan0.sql | 8 +- ...with_queried_group_by__plan0_optimized.sql | 6 +- ...est_simple_query_with_date_part__plan0.sql | 12 +- ..._query_with_multiple_date_parts__plan0.sql | 12 +- .../test_single_join_node__plan0.sql | 20 +- .../Databricks/test_source_node__plan0.sql | 12 +- .../test_source_node__plan0_optimized.sql | 12 +- .../test_common_semantic_model__plan0.sql | 24 +- ...common_semantic_model__plan0_optimized.sql | 6 +- .../test_compute_metrics_node__plan0.sql | 20 +- ...o_from_multiple_semantic_models__plan0.sql | 36 +- ...tiple_semantic_models__plan0_optimized.sql | 4 +- ...atio_from_single_semantic_model__plan0.sql | 20 +- ...ompute_metrics_node_simple_expr__plan0.sql | 20 +- .../test_constrain_time_range_node__plan0.sql | 12 +- ...train_time_range_node__plan0_optimized.sql | 6 +- .../DuckDB/test_cumulative_metric__plan0.sql | 4 +- ...cumulative_metric_grain_to_date__plan0.sql | 4 +- .../test_cumulative_metric_no_ds__plan0.sql | 4 +- ...est_cumulative_metric_no_window__plan0.sql | 4 +- ..._no_window_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- ...ive_metric_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- .../DuckDB/test_derived_metric__plan0.sql | 24 +- .../test_derived_metric__plan0_optimized.sql | 4 +- ...ved_metric_with_offset_to_grain__plan0.sql | 24 +- ..._with_offset_to_grain__plan0_optimized.sql | 4 +- ...offset_to_grain_and_granularity__plan0.sql | 24 +- ...grain_and_granularity__plan0_optimized.sql | 2 +- ...rived_metric_with_offset_window__plan0.sql | 24 +- ...ic_with_offset_window__plan0_optimized.sql | 4 +- ...h_offset_window_and_granularity__plan0.sql | 24 +- ...indow_and_granularity__plan0_optimized.sql | 2 +- ...fset_window_and_offset_to_grain__plan0.sql | 24 +- ...w_and_offset_to_grain__plan0_optimized.sql | 4 +- ...offset_to_grain_and_granularity__plan0.sql | 24 +- ...grain_and_granularity__plan0_optimized.sql | 4 +- ...erived_offset_cumulative_metric__plan0.sql | 12 +- ...set_cumulative_metric__plan0_optimized.sql | 4 +- ...et_metric_with_one_input_metric__plan0.sql | 12 +- ...with_one_input_metric__plan0_optimized.sql | 2 +- .../DuckDB/test_distinct_values__plan0.sql | 20 +- .../DuckDB/test_filter_node__plan0.sql | 12 +- ...lter_with_where_constraint_node__plan0.sql | 12 +- ...where_constraint_node__plan0_optimized.sql | 2 +- ...th_where_constraint_on_join_dim__plan0.sql | 20 +- .../test_join_to_scd_dimension__plan0.sql | 12 +- ...join_to_scd_dimension__plan0_optimized.sql | 2 +- ...spine_node_with_offset_to_grain__plan0.sql | 12 +- ..._with_offset_to_grain__plan0_optimized.sql | 4 +- ...e_spine_node_with_offset_window__plan0.sql | 12 +- ...de_with_offset_window__plan0_optimized.sql | 4 +- ..._time_spine_node_without_offset__plan0.sql | 12 +- ...e_node_without_offset__plan0_optimized.sql | 4 +- .../DuckDB/test_limit_rows__plan0.sql | 12 +- .../test_limit_rows__plan0_optimized.sql | 2 +- ...al_dimension_using_local_entity__plan0.sql | 8 +- .../test_measure_aggregation_node__plan0.sql | 12 +- .../DuckDB/test_measure_constraint__plan0.sql | 52 +-- ...st_measure_constraint__plan0_optimized.sql | 8 +- ..._constraint_with_reused_measure__plan0.sql | 24 +- ...t_with_reused_measure__plan0_optimized.sql | 6 +- ...aint_with_single_expr_and_alias__plan0.sql | 12 +- ...single_expr_and_alias__plan0_optimized.sql | 2 +- ..._multiple_sources_no_dimensions__plan0.sql | 20 +- ...multi_hop_through_scd_dimension__plan0.sql | 16 +- ...through_scd_dimension__plan0_optimized.sql | 2 +- ...test_multi_hop_to_scd_dimension__plan0.sql | 12 +- ..._hop_to_scd_dimension__plan0_optimized.sql | 2 +- .../DuckDB/test_multi_join_node__plan0.sql | 28 +- .../DuckDB/test_multihop_node__plan0.sql | 18 +- .../test_multihop_node__plan0_optimized.sql | 6 +- ..._multiple_metrics_no_dimensions__plan0.sql | 20 +- ...metrics_no_dimensions__plan0_optimized.sql | 4 +- .../test_nested_derived_metric__plan0.sql | 48 +- ...nested_derived_metric__plan0_optimized.sql | 8 +- ...st_offset_window_with_date_part__plan0.sql | 24 +- ...window_with_date_part__plan0_optimized.sql | 2 +- .../DuckDB/test_order_by_node__plan0.sql | 12 +- .../test_order_by_node__plan0_optimized.sql | 2 +- .../DuckDB/test_partitioned_join__plan0.sql | 20 +- ...test_partitioned_join__plan0_optimized.sql | 4 +- .../test_semi_additive_join_node__plan0.sql | 8 +- ...mi_additive_join_node__plan0_optimized.sql | 6 +- ...dditive_join_node_with_grouping__plan0.sql | 8 +- ...in_node_with_grouping__plan0_optimized.sql | 6 +- ...join_node_with_queried_group_by__plan0.sql | 8 +- ...with_queried_group_by__plan0_optimized.sql | 6 +- ...est_simple_query_with_date_part__plan0.sql | 12 +- ..._query_with_multiple_date_parts__plan0.sql | 12 +- .../DuckDB/test_single_join_node__plan0.sql | 20 +- .../DuckDB/test_source_node__plan0.sql | 12 +- .../test_source_node__plan0_optimized.sql | 12 +- .../test_common_semantic_model__plan0.sql | 24 +- ...common_semantic_model__plan0_optimized.sql | 6 +- .../test_compute_metrics_node__plan0.sql | 20 +- ...o_from_multiple_semantic_models__plan0.sql | 36 +- ...tiple_semantic_models__plan0_optimized.sql | 4 +- ...atio_from_single_semantic_model__plan0.sql | 20 +- ...ompute_metrics_node_simple_expr__plan0.sql | 20 +- .../test_constrain_time_range_node__plan0.sql | 12 +- ...train_time_range_node__plan0_optimized.sql | 6 +- .../test_cumulative_metric__plan0.sql | 4 +- ...cumulative_metric_grain_to_date__plan0.sql | 4 +- .../test_cumulative_metric_no_ds__plan0.sql | 4 +- ...est_cumulative_metric_no_window__plan0.sql | 4 +- ..._no_window_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- ...ive_metric_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- .../Postgres/test_derived_metric__plan0.sql | 24 +- .../test_derived_metric__plan0_optimized.sql | 4 +- ...ved_metric_with_offset_to_grain__plan0.sql | 24 +- ..._with_offset_to_grain__plan0_optimized.sql | 4 +- ...offset_to_grain_and_granularity__plan0.sql | 24 +- ...grain_and_granularity__plan0_optimized.sql | 2 +- ...rived_metric_with_offset_window__plan0.sql | 24 +- ...ic_with_offset_window__plan0_optimized.sql | 4 +- ...h_offset_window_and_granularity__plan0.sql | 24 +- ...indow_and_granularity__plan0_optimized.sql | 2 +- ...fset_window_and_offset_to_grain__plan0.sql | 24 +- ...w_and_offset_to_grain__plan0_optimized.sql | 4 +- ...offset_to_grain_and_granularity__plan0.sql | 24 +- ...grain_and_granularity__plan0_optimized.sql | 4 +- ...erived_offset_cumulative_metric__plan0.sql | 12 +- ...set_cumulative_metric__plan0_optimized.sql | 4 +- ...et_metric_with_one_input_metric__plan0.sql | 12 +- ...with_one_input_metric__plan0_optimized.sql | 2 +- .../Postgres/test_distinct_values__plan0.sql | 20 +- .../Postgres/test_filter_node__plan0.sql | 12 +- ...lter_with_where_constraint_node__plan0.sql | 12 +- ...where_constraint_node__plan0_optimized.sql | 2 +- ...th_where_constraint_on_join_dim__plan0.sql | 20 +- .../test_join_to_scd_dimension__plan0.sql | 12 +- ...join_to_scd_dimension__plan0_optimized.sql | 2 +- ...spine_node_with_offset_to_grain__plan0.sql | 12 +- ..._with_offset_to_grain__plan0_optimized.sql | 4 +- ...e_spine_node_with_offset_window__plan0.sql | 12 +- ...de_with_offset_window__plan0_optimized.sql | 4 +- ..._time_spine_node_without_offset__plan0.sql | 12 +- ...e_node_without_offset__plan0_optimized.sql | 4 +- .../Postgres/test_limit_rows__plan0.sql | 12 +- .../test_limit_rows__plan0_optimized.sql | 2 +- ...al_dimension_using_local_entity__plan0.sql | 8 +- .../test_measure_aggregation_node__plan0.sql | 12 +- .../test_measure_constraint__plan0.sql | 52 +-- ...st_measure_constraint__plan0_optimized.sql | 8 +- ..._constraint_with_reused_measure__plan0.sql | 24 +- ...t_with_reused_measure__plan0_optimized.sql | 6 +- ...aint_with_single_expr_and_alias__plan0.sql | 12 +- ...single_expr_and_alias__plan0_optimized.sql | 2 +- ..._multiple_sources_no_dimensions__plan0.sql | 20 +- ...multi_hop_through_scd_dimension__plan0.sql | 16 +- ...through_scd_dimension__plan0_optimized.sql | 2 +- ...test_multi_hop_to_scd_dimension__plan0.sql | 12 +- ..._hop_to_scd_dimension__plan0_optimized.sql | 2 +- .../Postgres/test_multi_join_node__plan0.sql | 28 +- .../Postgres/test_multihop_node__plan0.sql | 18 +- .../test_multihop_node__plan0_optimized.sql | 6 +- ..._multiple_metrics_no_dimensions__plan0.sql | 20 +- ...metrics_no_dimensions__plan0_optimized.sql | 4 +- .../test_nested_derived_metric__plan0.sql | 48 +- ...nested_derived_metric__plan0_optimized.sql | 8 +- ...st_offset_window_with_date_part__plan0.sql | 24 +- ...window_with_date_part__plan0_optimized.sql | 2 +- .../Postgres/test_order_by_node__plan0.sql | 12 +- .../test_order_by_node__plan0_optimized.sql | 2 +- .../Postgres/test_partitioned_join__plan0.sql | 20 +- ...test_partitioned_join__plan0_optimized.sql | 4 +- .../test_semi_additive_join_node__plan0.sql | 8 +- ...mi_additive_join_node__plan0_optimized.sql | 6 +- ...dditive_join_node_with_grouping__plan0.sql | 8 +- ...in_node_with_grouping__plan0_optimized.sql | 6 +- ...join_node_with_queried_group_by__plan0.sql | 8 +- ...with_queried_group_by__plan0_optimized.sql | 6 +- ...est_simple_query_with_date_part__plan0.sql | 12 +- ..._query_with_multiple_date_parts__plan0.sql | 12 +- .../Postgres/test_single_join_node__plan0.sql | 20 +- .../Postgres/test_source_node__plan0.sql | 12 +- .../test_source_node__plan0_optimized.sql | 12 +- .../test_common_semantic_model__plan0.sql | 24 +- ...common_semantic_model__plan0_optimized.sql | 6 +- .../test_compute_metrics_node__plan0.sql | 20 +- ...o_from_multiple_semantic_models__plan0.sql | 36 +- ...tiple_semantic_models__plan0_optimized.sql | 4 +- ...atio_from_single_semantic_model__plan0.sql | 20 +- ...ompute_metrics_node_simple_expr__plan0.sql | 20 +- .../test_constrain_time_range_node__plan0.sql | 12 +- ...train_time_range_node__plan0_optimized.sql | 6 +- .../test_cumulative_metric__plan0.sql | 4 +- ...cumulative_metric_grain_to_date__plan0.sql | 4 +- .../test_cumulative_metric_no_ds__plan0.sql | 4 +- ...est_cumulative_metric_no_window__plan0.sql | 4 +- ..._no_window_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- ...ive_metric_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- .../Redshift/test_derived_metric__plan0.sql | 24 +- .../test_derived_metric__plan0_optimized.sql | 4 +- ...ved_metric_with_offset_to_grain__plan0.sql | 24 +- ..._with_offset_to_grain__plan0_optimized.sql | 4 +- ...offset_to_grain_and_granularity__plan0.sql | 24 +- ...grain_and_granularity__plan0_optimized.sql | 2 +- ...rived_metric_with_offset_window__plan0.sql | 24 +- ...ic_with_offset_window__plan0_optimized.sql | 4 +- ...h_offset_window_and_granularity__plan0.sql | 24 +- ...indow_and_granularity__plan0_optimized.sql | 2 +- ...fset_window_and_offset_to_grain__plan0.sql | 24 +- ...w_and_offset_to_grain__plan0_optimized.sql | 4 +- ...offset_to_grain_and_granularity__plan0.sql | 24 +- ...grain_and_granularity__plan0_optimized.sql | 4 +- ...erived_offset_cumulative_metric__plan0.sql | 12 +- ...set_cumulative_metric__plan0_optimized.sql | 4 +- ...et_metric_with_one_input_metric__plan0.sql | 12 +- ...with_one_input_metric__plan0_optimized.sql | 2 +- .../Redshift/test_distinct_values__plan0.sql | 20 +- .../Redshift/test_filter_node__plan0.sql | 12 +- ...lter_with_where_constraint_node__plan0.sql | 12 +- ...where_constraint_node__plan0_optimized.sql | 2 +- ...th_where_constraint_on_join_dim__plan0.sql | 20 +- .../test_join_to_scd_dimension__plan0.sql | 12 +- ...join_to_scd_dimension__plan0_optimized.sql | 2 +- ...spine_node_with_offset_to_grain__plan0.sql | 12 +- ..._with_offset_to_grain__plan0_optimized.sql | 4 +- ...e_spine_node_with_offset_window__plan0.sql | 12 +- ...de_with_offset_window__plan0_optimized.sql | 4 +- ..._time_spine_node_without_offset__plan0.sql | 12 +- ...e_node_without_offset__plan0_optimized.sql | 4 +- .../Redshift/test_limit_rows__plan0.sql | 12 +- .../test_limit_rows__plan0_optimized.sql | 2 +- ...al_dimension_using_local_entity__plan0.sql | 8 +- .../test_measure_aggregation_node__plan0.sql | 12 +- .../test_measure_constraint__plan0.sql | 52 +-- ...st_measure_constraint__plan0_optimized.sql | 8 +- ..._constraint_with_reused_measure__plan0.sql | 24 +- ...t_with_reused_measure__plan0_optimized.sql | 6 +- ...aint_with_single_expr_and_alias__plan0.sql | 12 +- ...single_expr_and_alias__plan0_optimized.sql | 2 +- ..._multiple_sources_no_dimensions__plan0.sql | 20 +- ...multi_hop_through_scd_dimension__plan0.sql | 16 +- ...through_scd_dimension__plan0_optimized.sql | 2 +- ...test_multi_hop_to_scd_dimension__plan0.sql | 12 +- ..._hop_to_scd_dimension__plan0_optimized.sql | 2 +- .../Redshift/test_multi_join_node__plan0.sql | 28 +- .../Redshift/test_multihop_node__plan0.sql | 18 +- .../test_multihop_node__plan0_optimized.sql | 6 +- ..._multiple_metrics_no_dimensions__plan0.sql | 20 +- ...metrics_no_dimensions__plan0_optimized.sql | 4 +- .../test_nested_derived_metric__plan0.sql | 48 +- ...nested_derived_metric__plan0_optimized.sql | 8 +- ...st_offset_window_with_date_part__plan0.sql | 24 +- ...window_with_date_part__plan0_optimized.sql | 2 +- .../Redshift/test_order_by_node__plan0.sql | 12 +- .../test_order_by_node__plan0_optimized.sql | 2 +- .../Redshift/test_partitioned_join__plan0.sql | 20 +- ...test_partitioned_join__plan0_optimized.sql | 4 +- .../test_semi_additive_join_node__plan0.sql | 8 +- ...mi_additive_join_node__plan0_optimized.sql | 6 +- ...dditive_join_node_with_grouping__plan0.sql | 8 +- ...in_node_with_grouping__plan0_optimized.sql | 6 +- ...join_node_with_queried_group_by__plan0.sql | 8 +- ...with_queried_group_by__plan0_optimized.sql | 6 +- ...est_simple_query_with_date_part__plan0.sql | 12 +- ..._query_with_multiple_date_parts__plan0.sql | 12 +- .../Redshift/test_single_join_node__plan0.sql | 20 +- .../Redshift/test_source_node__plan0.sql | 12 +- .../test_source_node__plan0_optimized.sql | 12 +- .../test_common_semantic_model__plan0.sql | 24 +- ...common_semantic_model__plan0_optimized.sql | 6 +- .../test_compute_metrics_node__plan0.sql | 20 +- ...o_from_multiple_semantic_models__plan0.sql | 36 +- ...tiple_semantic_models__plan0_optimized.sql | 4 +- ...atio_from_single_semantic_model__plan0.sql | 20 +- ...ompute_metrics_node_simple_expr__plan0.sql | 20 +- .../test_constrain_time_range_node__plan0.sql | 12 +- ...train_time_range_node__plan0_optimized.sql | 6 +- .../test_cumulative_metric__plan0.sql | 4 +- ...cumulative_metric_grain_to_date__plan0.sql | 4 +- .../test_cumulative_metric_no_ds__plan0.sql | 4 +- ...est_cumulative_metric_no_window__plan0.sql | 4 +- ..._no_window_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- ...ive_metric_with_time_constraint__plan0.sql | 4 +- ..._with_time_constraint__plan0_optimized.sql | 2 +- .../Snowflake/test_derived_metric__plan0.sql | 24 +- .../test_derived_metric__plan0_optimized.sql | 4 +- ...ved_metric_with_offset_to_grain__plan0.sql | 24 +- ..._with_offset_to_grain__plan0_optimized.sql | 4 +- ...offset_to_grain_and_granularity__plan0.sql | 24 +- ...grain_and_granularity__plan0_optimized.sql | 2 +- ...rived_metric_with_offset_window__plan0.sql | 24 +- ...ic_with_offset_window__plan0_optimized.sql | 4 +- ...h_offset_window_and_granularity__plan0.sql | 24 +- ...indow_and_granularity__plan0_optimized.sql | 2 +- ...fset_window_and_offset_to_grain__plan0.sql | 24 +- ...w_and_offset_to_grain__plan0_optimized.sql | 4 +- ...offset_to_grain_and_granularity__plan0.sql | 24 +- ...grain_and_granularity__plan0_optimized.sql | 4 +- ...erived_offset_cumulative_metric__plan0.sql | 12 +- ...set_cumulative_metric__plan0_optimized.sql | 4 +- ...et_metric_with_one_input_metric__plan0.sql | 12 +- ...with_one_input_metric__plan0_optimized.sql | 2 +- .../Snowflake/test_distinct_values__plan0.sql | 20 +- .../Snowflake/test_filter_node__plan0.sql | 12 +- ...lter_with_where_constraint_node__plan0.sql | 12 +- ...where_constraint_node__plan0_optimized.sql | 2 +- ...th_where_constraint_on_join_dim__plan0.sql | 20 +- .../test_join_to_scd_dimension__plan0.sql | 12 +- ...join_to_scd_dimension__plan0_optimized.sql | 2 +- ...spine_node_with_offset_to_grain__plan0.sql | 12 +- ..._with_offset_to_grain__plan0_optimized.sql | 4 +- ...e_spine_node_with_offset_window__plan0.sql | 12 +- ...de_with_offset_window__plan0_optimized.sql | 4 +- ..._time_spine_node_without_offset__plan0.sql | 12 +- ...e_node_without_offset__plan0_optimized.sql | 4 +- .../Snowflake/test_limit_rows__plan0.sql | 12 +- .../test_limit_rows__plan0_optimized.sql | 2 +- ...al_dimension_using_local_entity__plan0.sql | 8 +- .../test_measure_aggregation_node__plan0.sql | 12 +- .../test_measure_constraint__plan0.sql | 52 +-- ...st_measure_constraint__plan0_optimized.sql | 8 +- ..._constraint_with_reused_measure__plan0.sql | 24 +- ...t_with_reused_measure__plan0_optimized.sql | 6 +- ...aint_with_single_expr_and_alias__plan0.sql | 12 +- ...single_expr_and_alias__plan0_optimized.sql | 2 +- ..._multiple_sources_no_dimensions__plan0.sql | 20 +- ...multi_hop_through_scd_dimension__plan0.sql | 16 +- ...through_scd_dimension__plan0_optimized.sql | 2 +- ...test_multi_hop_to_scd_dimension__plan0.sql | 12 +- ..._hop_to_scd_dimension__plan0_optimized.sql | 2 +- .../Snowflake/test_multi_join_node__plan0.sql | 28 +- .../Snowflake/test_multihop_node__plan0.sql | 18 +- .../test_multihop_node__plan0_optimized.sql | 6 +- ..._multiple_metrics_no_dimensions__plan0.sql | 20 +- ...metrics_no_dimensions__plan0_optimized.sql | 4 +- .../test_nested_derived_metric__plan0.sql | 48 +- ...nested_derived_metric__plan0_optimized.sql | 8 +- ...st_offset_window_with_date_part__plan0.sql | 24 +- ...window_with_date_part__plan0_optimized.sql | 2 +- .../Snowflake/test_order_by_node__plan0.sql | 12 +- .../test_order_by_node__plan0_optimized.sql | 2 +- .../test_partitioned_join__plan0.sql | 20 +- ...test_partitioned_join__plan0_optimized.sql | 4 +- .../test_semi_additive_join_node__plan0.sql | 8 +- ...mi_additive_join_node__plan0_optimized.sql | 6 +- ...dditive_join_node_with_grouping__plan0.sql | 8 +- ...in_node_with_grouping__plan0_optimized.sql | 6 +- ...join_node_with_queried_group_by__plan0.sql | 8 +- ...with_queried_group_by__plan0_optimized.sql | 6 +- ...est_simple_query_with_date_part__plan0.sql | 12 +- ..._query_with_multiple_date_parts__plan0.sql | 12 +- .../test_single_join_node__plan0.sql | 20 +- .../Snowflake/test_source_node__plan0.sql | 12 +- .../test_source_node__plan0_optimized.sql | 12 +- .../test_common_semantic_model__plan0.xml | 192 ++++---- .../test_compute_metrics_node__plan0.xml | 160 +++---- ...o_from_multiple_semantic_models__plan0.xml | 288 ++++++------ ...atio_from_single_semantic_model__plan0.xml | 160 +++---- ...ompute_metrics_node_simple_expr__plan0.xml | 160 +++---- .../test_constrain_time_range_node__plan0.xml | 96 ++-- .../test_cumulative_metric__plan0.xml | 32 +- ...cumulative_metric_grain_to_date__plan0.xml | 32 +- .../test_cumulative_metric_no_ds__plan0.xml | 32 +- ...est_cumulative_metric_no_window__plan0.xml | 32 +- ..._no_window_with_time_constraint__plan0.xml | 32 +- ...ive_metric_with_time_constraint__plan0.xml | 32 +- .../test_derived_metric__plan0.xml | 192 ++++---- ...ved_metric_with_offset_to_grain__plan0.xml | 192 ++++---- ...offset_to_grain_and_granularity__plan0.xml | 192 ++++---- ...rived_metric_with_offset_window__plan0.xml | 192 ++++---- ...h_offset_window_and_granularity__plan0.xml | 192 ++++---- ...fset_window_and_offset_to_grain__plan0.xml | 192 ++++---- ...offset_to_grain_and_granularity__plan0.xml | 192 ++++---- ...erived_offset_cumulative_metric__plan0.xml | 96 ++-- ...et_metric_with_one_input_metric__plan0.xml | 96 ++-- .../test_distinct_values__plan0.xml | 160 +++---- .../SqlQueryPlan/test_filter_node__plan0.xml | 96 ++-- ...lter_with_where_constraint_node__plan0.xml | 96 ++-- ...th_where_constraint_on_join_dim__plan0.xml | 160 +++---- .../test_join_to_scd_dimension__plan0.xml | 128 +++--- ...spine_node_with_offset_to_grain__plan0.xml | 96 ++-- ...e_spine_node_with_offset_window__plan0.xml | 96 ++-- ..._time_spine_node_without_offset__plan0.xml | 96 ++-- .../SqlQueryPlan/test_limit_rows__plan0.xml | 96 ++-- ...al_dimension_using_local_entity__plan0.xml | 64 +-- .../test_measure_aggregation_node__plan0.xml | 96 ++-- .../test_measure_constraint__plan0.xml | 416 +++++++++--------- ..._constraint_with_reused_measure__plan0.xml | 192 ++++---- ...aint_with_single_expr_and_alias__plan0.xml | 96 ++-- ..._multiple_sources_no_dimensions__plan0.xml | 160 +++---- ...multi_hop_through_scd_dimension__plan0.xml | 160 +++---- ...test_multi_hop_to_scd_dimension__plan0.xml | 128 +++--- .../test_multi_join_node__plan0.xml | 224 +++++----- .../test_multihop_node__plan0.xml | 144 +++--- ..._multiple_metrics_no_dimensions__plan0.xml | 160 +++---- .../test_nested_derived_metric__plan0.xml | 384 ++++++++-------- ...st_offset_window_with_date_part__plan0.xml | 192 ++++---- .../test_order_by_node__plan0.xml | 96 ++-- .../test_partitioned_join__plan0.xml | 160 +++---- .../test_semi_additive_join_node__plan0.xml | 64 +-- ...dditive_join_node_with_grouping__plan0.xml | 64 +-- ...join_node_with_queried_group_by__plan0.xml | 64 +-- ...est_simple_query_with_date_part__plan0.xml | 96 ++-- ..._query_with_multiple_date_parts__plan0.xml | 96 ++-- .../test_single_join_node__plan0.xml | 160 +++---- .../SqlQueryPlan/test_source_node__plan0.xml | 96 ++-- ...orm_node_using_non_primary_time__plan0.sql | 12 +- ...sing_non_primary_time__plan0_optimized.sql | 14 +- ...ansform_node_using_primary_time__plan0.sql | 12 +- ...de_using_primary_time__plan0_optimized.sql | 14 +- ...uery_with_metric_time_dimension__plan0.sql | 24 +- ...metric_time_dimension__plan0_optimized.sql | 4 +- ...orm_node_using_non_primary_time__plan0.sql | 12 +- ...sing_non_primary_time__plan0_optimized.sql | 14 +- ...ansform_node_using_primary_time__plan0.sql | 12 +- ...de_using_primary_time__plan0_optimized.sql | 14 +- ...uery_with_metric_time_dimension__plan0.sql | 24 +- ...metric_time_dimension__plan0_optimized.sql | 6 +- ...orm_node_using_non_primary_time__plan0.sql | 12 +- ...sing_non_primary_time__plan0_optimized.sql | 14 +- ...ansform_node_using_primary_time__plan0.sql | 12 +- ...de_using_primary_time__plan0_optimized.sql | 14 +- ...uery_with_metric_time_dimension__plan0.sql | 24 +- ...metric_time_dimension__plan0_optimized.sql | 6 +- ...orm_node_using_non_primary_time__plan0.sql | 12 +- ...sing_non_primary_time__plan0_optimized.sql | 14 +- ...ansform_node_using_primary_time__plan0.sql | 12 +- ...de_using_primary_time__plan0_optimized.sql | 14 +- ...uery_with_metric_time_dimension__plan0.sql | 24 +- ...metric_time_dimension__plan0_optimized.sql | 6 +- ...orm_node_using_non_primary_time__plan0.sql | 12 +- ...sing_non_primary_time__plan0_optimized.sql | 14 +- ...ansform_node_using_primary_time__plan0.sql | 12 +- ...de_using_primary_time__plan0_optimized.sql | 14 +- ...uery_with_metric_time_dimension__plan0.sql | 24 +- ...metric_time_dimension__plan0_optimized.sql | 6 +- ...orm_node_using_non_primary_time__plan0.sql | 12 +- ...sing_non_primary_time__plan0_optimized.sql | 14 +- ...ansform_node_using_primary_time__plan0.sql | 12 +- ...de_using_primary_time__plan0_optimized.sql | 14 +- ...uery_with_metric_time_dimension__plan0.sql | 24 +- ...metric_time_dimension__plan0_optimized.sql | 6 +- ...orm_node_using_non_primary_time__plan0.xml | 96 ++-- ...ansform_node_using_primary_time__plan0.xml | 96 ++-- ...uery_with_metric_time_dimension__plan0.xml | 192 ++++---- .../BigQuery/test_render_query__query0.sql | 2 +- ...st_render_write_to_table_query__query0.sql | 2 +- .../Databricks/test_render_query__query0.sql | 2 +- ...st_render_write_to_table_query__query0.sql | 2 +- .../DuckDB/test_render_query__query0.sql | 2 +- ...st_render_write_to_table_query__query0.sql | 2 +- .../Postgres/test_render_query__query0.sql | 2 +- ...st_render_write_to_table_query__query0.sql | 2 +- .../Redshift/test_render_query__query0.sql | 2 +- ...st_render_write_to_table_query__query0.sql | 2 +- .../Snowflake/test_render_query__query0.sql | 2 +- ...st_render_write_to_table_query__query0.sql | 2 +- 663 files changed, 7386 insertions(+), 7367 deletions(-) create mode 100644 .changes/unreleased/Fixes-20231005-124722.yaml diff --git a/.changes/unreleased/Fixes-20231005-124722.yaml b/.changes/unreleased/Fixes-20231005-124722.yaml new file mode 100644 index 0000000000..6cc367d7b4 --- /dev/null +++ b/.changes/unreleased/Fixes-20231005-124722.yaml @@ -0,0 +1,7 @@ +kind: Fixes +body: Coerce time granularity to configured value to prevent finer-grained timestamps + from causing unexpected query behavior +time: 2023-10-05T12:47:22.662371-07:00 +custom: + Author: tlento + Issue: "714" diff --git a/metricflow/dataset/convert_semantic_model.py b/metricflow/dataset/convert_semantic_model.py index c2b14936d2..e435e69c22 100644 --- a/metricflow/dataset/convert_semantic_model.py +++ b/metricflow/dataset/convert_semantic_model.py @@ -285,12 +285,24 @@ def _convert_time_dimension( time_granularity=defined_time_granularity, ) time_dimension_instances.append(time_dimension_instance) - select_columns.append( - SqlSelectColumn( - expr=dimension_select_expr, - column_alias=time_dimension_instance.associated_column.column_name, + + # Until we support minimal granularities, we cannot truncate for + # any time dimension used as part of a validity window, since a validity window might + # be stored in seconds while we would truncate to daily. + if dimension.validity_params: + select_columns.append( + SqlSelectColumn( + expr=dimension_select_expr, + column_alias=time_dimension_instance.associated_column.column_name, + ) + ) + else: + select_columns.append( + SqlSelectColumn( + expr=SqlDateTruncExpression(time_granularity=defined_time_granularity, arg=dimension_select_expr), + column_alias=time_dimension_instance.associated_column.column_name, + ) ) - ) # Add time dimensions with a smaller granularity for ease in query resolution for time_granularity in TimeGranularity: diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_query_semantic_model__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_query_semantic_model__plan0.sql index 95c23db647..dc74697f28 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_query_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_query_semantic_model__plan0.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC(revenue_src_10006.created_at, day) AS ds__day , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS ds__week , DATE_TRUNC(revenue_src_10006.created_at, month) AS ds__month , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC(revenue_src_10006.created_at, day) AS company__ds__day , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS company__ds__week , DATE_TRUNC(revenue_src_10006.created_at, month) AS company__ds__month , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_with_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_with_measures__plan0.sql index 21f374f1fe..687f7a17f3 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_with_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_with_measures__plan0.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , id_verifications_src_10003.ds AS ds__day + , DATE_TRUNC(id_verifications_src_10003.ds, day) AS ds__day , DATE_TRUNC(id_verifications_src_10003.ds, isoweek) AS ds__week , DATE_TRUNC(id_verifications_src_10003.ds, month) AS ds__month , DATE_TRUNC(id_verifications_src_10003.ds, quarter) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day , EXTRACT(dayofweek FROM id_verifications_src_10003.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM id_verifications_src_10003.ds) AS ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -26,7 +26,7 @@ SELECT , EXTRACT(dayofweek FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy , id_verifications_src_10003.verification_type - , id_verifications_src_10003.ds AS verification__ds__day + , DATE_TRUNC(id_verifications_src_10003.ds, day) AS verification__ds__day , DATE_TRUNC(id_verifications_src_10003.ds, isoweek) AS verification__ds__week , DATE_TRUNC(id_verifications_src_10003.ds, month) AS verification__ds__month , DATE_TRUNC(id_verifications_src_10003.ds, quarter) AS verification__ds__quarter @@ -38,7 +38,7 @@ SELECT , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day , EXTRACT(dayofweek FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow , EXTRACT(dayofyear FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS verification__ds_partitioned__day + , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, day) AS verification__ds_partitioned__day , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, isoweek) AS verification__ds_partitioned__week , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, month) AS verification__ds_partitioned__month , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, quarter) AS verification__ds_partitioned__quarter diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_without_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_without_measures__plan0.sql index e78994d824..1ad6542721 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_without_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/BigQuery/test_convert_table_semantic_model_without_measures__plan0.sql @@ -1,6 +1,6 @@ -- Read Elements From Semantic Model 'users_latest' SELECT - users_latest_src_10008.ds AS ds_latest__day + DATE_TRUNC(users_latest_src_10008.ds, day) AS ds_latest__day , DATE_TRUNC(users_latest_src_10008.ds, isoweek) AS ds_latest__week , DATE_TRUNC(users_latest_src_10008.ds, month) AS ds_latest__month , DATE_TRUNC(users_latest_src_10008.ds, quarter) AS ds_latest__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(dayofweek FROM users_latest_src_10008.ds) AS ds_latest__extract_dow , EXTRACT(dayofyear FROM users_latest_src_10008.ds) AS ds_latest__extract_doy , users_latest_src_10008.home_state_latest - , users_latest_src_10008.ds AS user__ds_latest__day + , DATE_TRUNC(users_latest_src_10008.ds, day) AS user__ds_latest__day , DATE_TRUNC(users_latest_src_10008.ds, isoweek) AS user__ds_latest__week , DATE_TRUNC(users_latest_src_10008.ds, month) AS user__ds_latest__month , DATE_TRUNC(users_latest_src_10008.ds, quarter) AS user__ds_latest__quarter diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_query_semantic_model__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_query_semantic_model__plan0.sql index dab2be52a2..78cf2a977d 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_query_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_query_semantic_model__plan0.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_with_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_with_measures__plan0.sql index 93f9b1f47a..c80e4dc22e 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_with_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_with_measures__plan0.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , id_verifications_src_10003.ds AS ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter @@ -26,7 +26,7 @@ SELECT , EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy , id_verifications_src_10003.verification_type - , id_verifications_src_10003.ds AS verification__ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter @@ -38,7 +38,7 @@ SELECT , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS verification__ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_without_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_without_measures__plan0.sql index 184fc0044a..2cc50cba73 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_without_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Databricks/test_convert_table_semantic_model_without_measures__plan0.sql @@ -1,6 +1,6 @@ -- Read Elements From Semantic Model 'users_latest' SELECT - users_latest_src_10008.ds AS ds_latest__day + DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(dow FROM users_latest_src_10008.ds) AS ds_latest__extract_dow , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy , users_latest_src_10008.home_state_latest - , users_latest_src_10008.ds AS user__ds_latest__day + , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_query_semantic_model__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_query_semantic_model__plan0.sql index dab2be52a2..78cf2a977d 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_query_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_query_semantic_model__plan0.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_with_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_with_measures__plan0.sql index 93f9b1f47a..c80e4dc22e 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_with_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_with_measures__plan0.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , id_verifications_src_10003.ds AS ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter @@ -26,7 +26,7 @@ SELECT , EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy , id_verifications_src_10003.verification_type - , id_verifications_src_10003.ds AS verification__ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter @@ -38,7 +38,7 @@ SELECT , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS verification__ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_without_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_without_measures__plan0.sql index 184fc0044a..2cc50cba73 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_without_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/DuckDB/test_convert_table_semantic_model_without_measures__plan0.sql @@ -1,6 +1,6 @@ -- Read Elements From Semantic Model 'users_latest' SELECT - users_latest_src_10008.ds AS ds_latest__day + DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(dow FROM users_latest_src_10008.ds) AS ds_latest__extract_dow , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy , users_latest_src_10008.home_state_latest - , users_latest_src_10008.ds AS user__ds_latest__day + , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_query_semantic_model__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_query_semantic_model__plan0.sql index dab2be52a2..78cf2a977d 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_query_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_query_semantic_model__plan0.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_with_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_with_measures__plan0.sql index 93f9b1f47a..c80e4dc22e 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_with_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_with_measures__plan0.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , id_verifications_src_10003.ds AS ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter @@ -26,7 +26,7 @@ SELECT , EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy , id_verifications_src_10003.verification_type - , id_verifications_src_10003.ds AS verification__ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter @@ -38,7 +38,7 @@ SELECT , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS verification__ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_without_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_without_measures__plan0.sql index 184fc0044a..2cc50cba73 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_without_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Postgres/test_convert_table_semantic_model_without_measures__plan0.sql @@ -1,6 +1,6 @@ -- Read Elements From Semantic Model 'users_latest' SELECT - users_latest_src_10008.ds AS ds_latest__day + DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(dow FROM users_latest_src_10008.ds) AS ds_latest__extract_dow , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy , users_latest_src_10008.home_state_latest - , users_latest_src_10008.ds AS user__ds_latest__day + , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_query_semantic_model__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_query_semantic_model__plan0.sql index dab2be52a2..78cf2a977d 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_query_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_query_semantic_model__plan0.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_with_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_with_measures__plan0.sql index 93f9b1f47a..c80e4dc22e 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_with_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_with_measures__plan0.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , id_verifications_src_10003.ds AS ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter @@ -26,7 +26,7 @@ SELECT , EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy , id_verifications_src_10003.verification_type - , id_verifications_src_10003.ds AS verification__ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter @@ -38,7 +38,7 @@ SELECT , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS verification__ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_without_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_without_measures__plan0.sql index 184fc0044a..2cc50cba73 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_without_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Redshift/test_convert_table_semantic_model_without_measures__plan0.sql @@ -1,6 +1,6 @@ -- Read Elements From Semantic Model 'users_latest' SELECT - users_latest_src_10008.ds AS ds_latest__day + DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(dow FROM users_latest_src_10008.ds) AS ds_latest__extract_dow , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy , users_latest_src_10008.home_state_latest - , users_latest_src_10008.ds AS user__ds_latest__day + , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_query_semantic_model__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_query_semantic_model__plan0.sql index dab2be52a2..78cf2a977d 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_query_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_query_semantic_model__plan0.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_with_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_with_measures__plan0.sql index 93f9b1f47a..c80e4dc22e 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_with_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_with_measures__plan0.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , id_verifications_src_10003.ds AS ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter @@ -26,7 +26,7 @@ SELECT , EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy , id_verifications_src_10003.verification_type - , id_verifications_src_10003.ds AS verification__ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter @@ -38,7 +38,7 @@ SELECT , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS verification__ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter diff --git a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_without_measures__plan0.sql b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_without_measures__plan0.sql index 184fc0044a..2cc50cba73 100644 --- a/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_without_measures__plan0.sql +++ b/metricflow/test/snapshots/test_convert_semantic_model.py/SqlQueryPlan/Snowflake/test_convert_table_semantic_model_without_measures__plan0.sql @@ -1,6 +1,6 @@ -- Read Elements From Semantic Model 'users_latest' SELECT - users_latest_src_10008.ds AS ds_latest__day + DATE_TRUNC('day', users_latest_src_10008.ds) AS ds_latest__day , DATE_TRUNC('week', users_latest_src_10008.ds) AS ds_latest__week , DATE_TRUNC('month', users_latest_src_10008.ds) AS ds_latest__month , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS ds_latest__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(dow FROM users_latest_src_10008.ds) AS ds_latest__extract_dow , EXTRACT(doy FROM users_latest_src_10008.ds) AS ds_latest__extract_doy , users_latest_src_10008.home_state_latest - , users_latest_src_10008.ds AS user__ds_latest__day + , DATE_TRUNC('day', users_latest_src_10008.ds) AS user__ds_latest__day , DATE_TRUNC('week', users_latest_src_10008.ds) AS user__ds_latest__week , DATE_TRUNC('month', users_latest_src_10008.ds) AS user__ds_latest__month , DATE_TRUNC('quarter', users_latest_src_10008.ds) AS user__ds_latest__quarter diff --git a/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/BigQuery/test_build_metric_tasks__query0.sql b/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/BigQuery/test_build_metric_tasks__query0.sql index 801df5acef..81221ddb4c 100644 --- a/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/BigQuery/test_build_metric_tasks__query0.sql +++ b/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/BigQuery/test_build_metric_tasks__query0.sql @@ -9,7 +9,7 @@ FROM ( -- Pass Only Elements: -- ['count_dogs', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS count_dogs FROM ***************************.fct_animals animals_src_0 ) subq_2 diff --git a/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/Databricks/test_build_metric_tasks__query0.sql b/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/Databricks/test_build_metric_tasks__query0.sql index 801df5acef..a8484a1d11 100644 --- a/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/Databricks/test_build_metric_tasks__query0.sql +++ b/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/Databricks/test_build_metric_tasks__query0.sql @@ -9,7 +9,7 @@ FROM ( -- Pass Only Elements: -- ['count_dogs', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS count_dogs FROM ***************************.fct_animals animals_src_0 ) subq_2 diff --git a/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/DuckDB/test_build_metric_tasks__query0.sql b/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/DuckDB/test_build_metric_tasks__query0.sql index 801df5acef..a8484a1d11 100644 --- a/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/DuckDB/test_build_metric_tasks__query0.sql +++ b/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/DuckDB/test_build_metric_tasks__query0.sql @@ -9,7 +9,7 @@ FROM ( -- Pass Only Elements: -- ['count_dogs', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS count_dogs FROM ***************************.fct_animals animals_src_0 ) subq_2 diff --git a/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/Postgres/test_build_metric_tasks__query0.sql b/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/Postgres/test_build_metric_tasks__query0.sql index 801df5acef..a8484a1d11 100644 --- a/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/Postgres/test_build_metric_tasks__query0.sql +++ b/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/Postgres/test_build_metric_tasks__query0.sql @@ -9,7 +9,7 @@ FROM ( -- Pass Only Elements: -- ['count_dogs', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS count_dogs FROM ***************************.fct_animals animals_src_0 ) subq_2 diff --git a/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/Redshift/test_build_metric_tasks__query0.sql b/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/Redshift/test_build_metric_tasks__query0.sql index 801df5acef..a8484a1d11 100644 --- a/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/Redshift/test_build_metric_tasks__query0.sql +++ b/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/Redshift/test_build_metric_tasks__query0.sql @@ -9,7 +9,7 @@ FROM ( -- Pass Only Elements: -- ['count_dogs', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS count_dogs FROM ***************************.fct_animals animals_src_0 ) subq_2 diff --git a/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/Snowflake/test_build_metric_tasks__query0.sql b/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/Snowflake/test_build_metric_tasks__query0.sql index 801df5acef..a8484a1d11 100644 --- a/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/Snowflake/test_build_metric_tasks__query0.sql +++ b/metricflow/test/snapshots/test_data_warehouse_tasks.py/data_warehouse_validation_manifest/Snowflake/test_build_metric_tasks__query0.sql @@ -9,7 +9,7 @@ FROM ( -- Pass Only Elements: -- ['count_dogs', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS count_dogs FROM ***************************.fct_animals animals_src_0 ) subq_2 diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_combined_metrics_plan__ep_0.xml index b93d015874..d9513dae5f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_combined_metrics_plan__ep_0.xml @@ -23,7 +23,7 @@ - + @@ -45,7 +45,7 @@ - + @@ -68,7 +68,7 @@ - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml index b190e5dca1..b76e1367e7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/BigQuery/test_multihop_joined_plan__ep_0.xml @@ -2,41 +2,41 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_combined_metrics_plan__ep_0.xml index 0d2369dcca..1768aeaecd 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_combined_metrics_plan__ep_0.xml @@ -23,7 +23,7 @@ - + @@ -45,7 +45,7 @@ - + @@ -68,12 +68,12 @@ - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml index 99b6619da9..ab375ac0d1 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Databricks/test_multihop_joined_plan__ep_0.xml @@ -2,41 +2,41 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_combined_metrics_plan__ep_0.xml index 0d2369dcca..1768aeaecd 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_combined_metrics_plan__ep_0.xml @@ -23,7 +23,7 @@ - + @@ -45,7 +45,7 @@ - + @@ -68,12 +68,12 @@ - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_multihop_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_multihop_joined_plan__ep_0.xml index 99b6619da9..ab375ac0d1 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_multihop_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/DuckDB/test_multihop_joined_plan__ep_0.xml @@ -2,41 +2,41 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_combined_metrics_plan__ep_0.xml index 0d2369dcca..1768aeaecd 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_combined_metrics_plan__ep_0.xml @@ -23,7 +23,7 @@ - + @@ -45,7 +45,7 @@ - + @@ -68,12 +68,12 @@ - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml index 99b6619da9..ab375ac0d1 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Postgres/test_multihop_joined_plan__ep_0.xml @@ -2,41 +2,41 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_combined_metrics_plan__ep_0.xml index 0d2369dcca..1768aeaecd 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_combined_metrics_plan__ep_0.xml @@ -23,7 +23,7 @@ - + @@ -45,7 +45,7 @@ - + @@ -68,12 +68,12 @@ - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml index 99b6619da9..ab375ac0d1 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Redshift/test_multihop_joined_plan__ep_0.xml @@ -2,41 +2,41 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_combined_metrics_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_combined_metrics_plan__ep_0.xml index 0d2369dcca..1768aeaecd 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_combined_metrics_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_combined_metrics_plan__ep_0.xml @@ -23,7 +23,7 @@ - + @@ -45,7 +45,7 @@ - + @@ -68,12 +68,12 @@ - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml index 99b6619da9..ab375ac0d1 100644 --- a/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_execution.py/ExecutionPlan/Snowflake/test_multihop_joined_plan__ep_0.xml @@ -2,41 +2,41 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_common_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_common_semantic_model__plan0.sql index eda032ff2f..7629c26bcc 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_common_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_common_semantic_model__plan0.sql @@ -145,7 +145,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -157,7 +157,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -182,7 +182,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -374,7 +374,7 @@ FULL OUTER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -386,7 +386,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -398,7 +398,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -411,7 +411,7 @@ FULL OUTER JOIN ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -423,7 +423,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -435,7 +435,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_common_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_common_semantic_model__plan0_optimized.sql index 093cac2093..bb0ddce058 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_common_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_common_semantic_model__plan0_optimized.sql @@ -15,7 +15,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_12 @@ -30,7 +30,7 @@ FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0.sql index ed7c79b643..d142fb9721 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node__plan0.sql @@ -39,7 +39,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -51,7 +51,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -76,7 +76,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -88,7 +88,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -100,7 +100,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -133,7 +133,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter @@ -145,7 +145,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter @@ -160,7 +160,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index 178465c7ed..b7bda255c0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -169,7 +169,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -218,7 +218,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -230,7 +230,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -339,7 +339,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter @@ -351,7 +351,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter @@ -366,7 +366,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter @@ -378,7 +378,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter @@ -514,7 +514,7 @@ FROM ( -- Read Elements From Semantic Model 'views_source' SELECT 1 AS views - , views_source_src_10009.ds AS ds__day + , DATE_TRUNC(views_source_src_10009.ds, day) AS ds__day , DATE_TRUNC(views_source_src_10009.ds, isoweek) AS ds__week , DATE_TRUNC(views_source_src_10009.ds, month) AS ds__month , DATE_TRUNC(views_source_src_10009.ds, quarter) AS ds__quarter @@ -526,7 +526,7 @@ FROM ( , EXTRACT(day FROM views_source_src_10009.ds) AS ds__extract_day , EXTRACT(dayofweek FROM views_source_src_10009.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM views_source_src_10009.ds) AS ds__extract_doy - , views_source_src_10009.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(views_source_src_10009.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(views_source_src_10009.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(views_source_src_10009.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(views_source_src_10009.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -538,7 +538,7 @@ FROM ( , EXTRACT(day FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_doy - , views_source_src_10009.ds AS view__ds__day + , DATE_TRUNC(views_source_src_10009.ds, day) AS view__ds__day , DATE_TRUNC(views_source_src_10009.ds, isoweek) AS view__ds__week , DATE_TRUNC(views_source_src_10009.ds, month) AS view__ds__month , DATE_TRUNC(views_source_src_10009.ds, quarter) AS view__ds__quarter @@ -550,7 +550,7 @@ FROM ( , EXTRACT(day FROM views_source_src_10009.ds) AS view__ds__extract_day , EXTRACT(dayofweek FROM views_source_src_10009.ds) AS view__ds__extract_dow , EXTRACT(dayofyear FROM views_source_src_10009.ds) AS view__ds__extract_doy - , views_source_src_10009.ds_partitioned AS view__ds_partitioned__day + , DATE_TRUNC(views_source_src_10009.ds_partitioned, day) AS view__ds_partitioned__day , DATE_TRUNC(views_source_src_10009.ds_partitioned, isoweek) AS view__ds_partitioned__week , DATE_TRUNC(views_source_src_10009.ds_partitioned, month) AS view__ds_partitioned__month , DATE_TRUNC(views_source_src_10009.ds_partitioned, quarter) AS view__ds_partitioned__quarter @@ -657,7 +657,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter @@ -669,7 +669,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter @@ -684,7 +684,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter @@ -696,7 +696,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index f942f0d568..e540931fcd 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'ds__day', 'listing'] SELECT - ds AS ds__day + DATE_TRUNC(ds, day) AS ds__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 @@ -49,7 +49,7 @@ INNER JOIN ( -- Pass Only Elements: -- ['views', 'ds__day', 'listing'] SELECT - ds AS ds__day + DATE_TRUNC(ds, day) AS ds__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_10009 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql index 8969f7a6c0..3daf94c62d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql @@ -42,7 +42,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -54,7 +54,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -66,7 +66,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -79,7 +79,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -91,7 +91,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -103,7 +103,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -136,7 +136,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter @@ -148,7 +148,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter @@ -163,7 +163,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter @@ -175,7 +175,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0.sql index 1ddd22d435..2fdb6e5e92 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_compute_metrics_node_simple_expr__plan0.sql @@ -39,7 +39,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -51,7 +51,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -76,7 +76,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -88,7 +88,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -100,7 +100,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -133,7 +133,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter @@ -145,7 +145,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter @@ -160,7 +160,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_constrain_time_range_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_constrain_time_range_node__plan0.sql index 7e50393d6d..c68010345b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_constrain_time_range_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_constrain_time_range_node__plan0.sql @@ -33,7 +33,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -45,7 +45,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -57,7 +57,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -70,7 +70,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -82,7 +82,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -94,7 +94,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_constrain_time_range_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_constrain_time_range_node__plan0_optimized.sql index bfc4959615..ad8630e347 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_constrain_time_range_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_constrain_time_range_node__plan0_optimized.sql @@ -4,8 +4,8 @@ -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - ds AS ds__day - , ds AS metric_time__day + DATE_TRUNC(ds, day) AS ds__day + , DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 -WHERE ds BETWEEN '2020-01-01' AND '2020-01-02' +WHERE DATE_TRUNC(ds, day) BETWEEN '2020-01-01' AND '2020-01-02' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0.sql index bd9b392402..ee098f9301 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric__plan0.sql @@ -59,7 +59,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC(revenue_src_10006.created_at, day) AS ds__day , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS ds__week , DATE_TRUNC(revenue_src_10006.created_at, month) AS ds__month , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS ds__quarter @@ -71,7 +71,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC(revenue_src_10006.created_at, day) AS company__ds__day , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS company__ds__week , DATE_TRUNC(revenue_src_10006.created_at, month) AS company__ds__month , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0.sql index 639e816eb6..f9efef37cf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_grain_to_date__plan0.sql @@ -59,7 +59,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC(revenue_src_10006.created_at, day) AS ds__day , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS ds__week , DATE_TRUNC(revenue_src_10006.created_at, month) AS ds__month , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS ds__quarter @@ -71,7 +71,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC(revenue_src_10006.created_at, day) AS company__ds__day , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS company__ds__week , DATE_TRUNC(revenue_src_10006.created_at, month) AS company__ds__month , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0.sql index cd58d0ce0d..6b372fb03f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_ds__plan0.sql @@ -56,7 +56,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC(revenue_src_10006.created_at, day) AS ds__day , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS ds__week , DATE_TRUNC(revenue_src_10006.created_at, month) AS ds__month , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS ds__quarter @@ -68,7 +68,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC(revenue_src_10006.created_at, day) AS company__ds__day , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS company__ds__week , DATE_TRUNC(revenue_src_10006.created_at, month) AS company__ds__month , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0.sql index 35cc71b613..750a7f1d40 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window__plan0.sql @@ -59,7 +59,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC(revenue_src_10006.created_at, day) AS ds__day , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS ds__week , DATE_TRUNC(revenue_src_10006.created_at, month) AS ds__month , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS ds__quarter @@ -71,7 +71,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC(revenue_src_10006.created_at, day) AS company__ds__day , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS company__ds__week , DATE_TRUNC(revenue_src_10006.created_at, month) AS company__ds__month , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 829e30ded9..6b3f4f7e49 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -101,7 +101,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC(revenue_src_10006.created_at, day) AS ds__day , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS ds__week , DATE_TRUNC(revenue_src_10006.created_at, month) AS ds__month , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS ds__quarter @@ -113,7 +113,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC(revenue_src_10006.created_at, day) AS company__ds__day , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS company__ds__week , DATE_TRUNC(revenue_src_10006.created_at, month) AS company__ds__month , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index 4602e31115..aa655a506a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -9,6 +9,6 @@ SELECT DATE_TRUNC(created_at, month) AS ds__month , SUM(revenue) AS revenue_all_time FROM ***************************.fct_revenue revenue_src_10006 -WHERE created_at BETWEEN '2000-01-01' AND '2020-01-01' +WHERE DATE_TRUNC(created_at, day) BETWEEN '2000-01-01' AND '2020-01-01' GROUP BY ds__month diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql index c8630b8f49..2985cf8a8e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0.sql @@ -101,7 +101,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC(revenue_src_10006.created_at, day) AS ds__day , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS ds__week , DATE_TRUNC(revenue_src_10006.created_at, month) AS ds__month , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS ds__quarter @@ -113,7 +113,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC(revenue_src_10006.created_at, day) AS company__ds__day , DATE_TRUNC(revenue_src_10006.created_at, isoweek) AS company__ds__week , DATE_TRUNC(revenue_src_10006.created_at, month) AS company__ds__month , DATE_TRUNC(revenue_src_10006.created_at, quarter) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index 3b9dc85205..6c8ef1f575 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -9,6 +9,6 @@ SELECT DATE_TRUNC(created_at, month) AS ds__month , SUM(revenue) AS trailing_2_months_revenue FROM ***************************.fct_revenue revenue_src_10006 -WHERE created_at BETWEEN '2019-12-01' AND '2020-01-01' +WHERE DATE_TRUNC(created_at, day) BETWEEN '2019-12-01' AND '2020-01-01' GROUP BY ds__month diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0.sql index ffc899b824..b45ee2f8ed 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -379,7 +379,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -391,7 +391,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -403,7 +403,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -416,7 +416,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -428,7 +428,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -440,7 +440,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0_optimized.sql index 336e7623a6..90acc82428 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['referred_bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_13 @@ -39,7 +39,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_18 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql index 2705007543..11ba03b8fa 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index 3ef31443ec..808e5ad197 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_16 @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index 7d7c920907..137bc5af4f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index b84d324286..e60f75c802 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql index 62768ac034..e1015d6fbc 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0_optimized.sql index 7c7c7bfb7b..10852db154 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_16 @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 229acaf841..f1d30bea48 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index ae2f17cb3e..3d1eeb5c25 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index a4c8b503e4..de6f36bcaf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -253,7 +253,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -265,7 +265,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -277,7 +277,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -290,7 +290,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -302,7 +302,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -314,7 +314,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -588,7 +588,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -600,7 +600,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -612,7 +612,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -625,7 +625,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -637,7 +637,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -649,7 +649,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index fffc483657..d9ee2344b2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -22,7 +22,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_18 @@ -45,7 +45,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_26 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index 9107fdbe8a..6b93982e74 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -253,7 +253,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -265,7 +265,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -277,7 +277,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -290,7 +290,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -302,7 +302,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -314,7 +314,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -589,7 +589,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -601,7 +601,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -613,7 +613,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -626,7 +626,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -638,7 +638,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -650,7 +650,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 81517743d0..e0ea67dae8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -22,7 +22,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_18 @@ -46,7 +46,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_26 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0.sql index 0d9742944b..901fc885e4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0.sql @@ -361,7 +361,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -373,7 +373,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -385,7 +385,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -398,7 +398,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -410,7 +410,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -422,7 +422,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0_optimized.sql index e0593d04a8..fcc27943ec 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -22,9 +22,9 @@ FROM ( ***************************.fct_bookings bookings_source_src_10001 ON ( - bookings_source_src_10001.ds <= subq_14.ds + DATE_TRUNC(bookings_source_src_10001.ds, day) <= subq_14.ds ) AND ( - bookings_source_src_10001.ds > DATE_SUB(CAST(subq_14.ds AS DATETIME), INTERVAL 2 day) + DATE_TRUNC(bookings_source_src_10001.ds, day) > DATE_SUB(CAST(subq_14.ds AS DATETIME), INTERVAL 2 day) ) ) subq_15 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0.sql index 13415b0ae2..2a14cd443f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -247,7 +247,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -259,7 +259,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -271,7 +271,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -284,7 +284,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -296,7 +296,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -308,7 +308,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index 8a9c29a7a9..8455127f66 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -16,7 +16,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_9 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0.sql index 5c0e215038..837156f409 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_distinct_values__plan0.sql @@ -160,7 +160,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -184,7 +184,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -197,7 +197,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -209,7 +209,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -221,7 +221,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -330,7 +330,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter @@ -342,7 +342,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter @@ -357,7 +357,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter @@ -369,7 +369,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_node__plan0.sql index 12f6f6e38a..5248e8ad8e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_node__plan0.sql @@ -20,7 +20,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -32,7 +32,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -44,7 +44,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -57,7 +57,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -69,7 +69,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -81,7 +81,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_node__plan0.sql index d13bb8fafe..9ccf0c2839 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_node__plan0.sql @@ -26,7 +26,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -38,7 +38,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -75,7 +75,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -87,7 +87,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_node__plan0_optimized.sql index c850362ca3..57167c9663 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_node__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'ds__day'] SELECT - ds AS ds__day + DATE_TRUNC(ds, day) AS ds__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_3 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0.sql index a4205ece06..d525467c33 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -166,7 +166,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -178,7 +178,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -190,7 +190,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -203,7 +203,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -215,7 +215,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -227,7 +227,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -336,7 +336,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter @@ -348,7 +348,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter @@ -363,7 +363,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter @@ -375,7 +375,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0.sql index 1d933aaf04..e0fb1c7766 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0.sql @@ -154,7 +154,7 @@ FROM ( , bookings_source_src_10015.booking_value AS average_booking_value , bookings_source_src_10015.booking_value AS booking_payments , bookings_source_src_10015.is_instant - , bookings_source_src_10015.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10015.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10015.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10015.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10015.ds, quarter) AS ds__quarter @@ -166,7 +166,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10015.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10015.ds) AS ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -178,7 +178,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10015.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10015.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10015.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10015.paid_at, quarter) AS paid_at__quarter @@ -191,7 +191,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy , bookings_source_src_10015.is_instant AS booking__is_instant - , bookings_source_src_10015.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10015.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10015.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10015.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10015.ds, quarter) AS booking__ds__quarter @@ -203,7 +203,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -215,7 +215,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10015.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10015.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10015.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10015.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0_optimized.sql index 86a2010b35..d9dff12ede 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_scd_dimension__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10015 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index fd5aaaa276..73e631dc80 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -155,7 +155,7 @@ INNER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -167,7 +167,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -179,7 +179,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -192,7 +192,7 @@ INNER JOIN ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -204,7 +204,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -216,7 +216,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index 3b6ed20f77..8d5ffc259f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -23,7 +23,7 @@ INNER JOIN ( -- ['booking_value', 'metric_time__day', 'listing'] -- Aggregate Measures SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0.sql index 438ffdddad..ad37811541 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -155,7 +155,7 @@ INNER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -167,7 +167,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -179,7 +179,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -192,7 +192,7 @@ INNER JOIN ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -204,7 +204,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -216,7 +216,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index 6fce290360..6fe025f88f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -23,7 +23,7 @@ INNER JOIN ( -- ['booking_value', 'metric_time__day', 'listing'] -- Aggregate Measures SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0.sql index 919c372968..1e6b51b9b4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0.sql @@ -155,7 +155,7 @@ INNER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -167,7 +167,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -179,7 +179,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -192,7 +192,7 @@ INNER JOIN ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -204,7 +204,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -216,7 +216,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index c35fc3c24d..79a0b9c791 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -23,7 +23,7 @@ INNER JOIN ( -- ['booking_value', 'metric_time__day', 'listing'] -- Aggregate Measures SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_limit_rows__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_limit_rows__plan0.sql index 9bedbf14e2..564a160581 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_limit_rows__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_limit_rows__plan0.sql @@ -144,7 +144,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -156,7 +156,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_limit_rows__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_limit_rows__plan0_optimized.sql index 6db56759fc..e5ac4f260e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_limit_rows__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_limit_rows__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'ds__day'] SELECT - ds AS ds__day + DATE_TRUNC(ds, day) AS ds__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_7 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0.sql index 5ee683c896..e65df6e048 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_local_dimension_using_local_entity__plan0.sql @@ -94,7 +94,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter @@ -106,7 +106,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter @@ -121,7 +121,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter @@ -133,7 +133,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_aggregation_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_aggregation_node__plan0.sql index ff2afccd69..905e028275 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_aggregation_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_aggregation_node__plan0.sql @@ -30,7 +30,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -42,7 +42,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -54,7 +54,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -67,7 +67,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -79,7 +79,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -91,7 +91,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql index 77cede8ad4..f60140e020 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0.sql @@ -178,7 +178,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -190,7 +190,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -202,7 +202,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -215,7 +215,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -227,7 +227,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -239,7 +239,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -348,7 +348,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter @@ -360,7 +360,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter @@ -375,7 +375,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter @@ -387,7 +387,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter @@ -589,7 +589,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -601,7 +601,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -613,7 +613,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -626,7 +626,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -638,7 +638,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -650,7 +650,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -759,7 +759,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter @@ -771,7 +771,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter @@ -786,7 +786,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter @@ -798,7 +798,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter @@ -983,7 +983,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -995,7 +995,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -1007,7 +1007,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -1020,7 +1020,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -1032,7 +1032,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -1044,7 +1044,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0_optimized.sql index 6905cd9866..e3a2f21877 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint__plan0_optimized.sql @@ -23,7 +23,7 @@ FROM ( -- Pass Only Elements: -- ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - bookings_source_src_10001.ds AS metric_time__day + DATE_TRUNC(bookings_source_src_10001.ds, day) AS metric_time__day , listings_latest_src_10004.is_lux AS listing__is_lux_latest , bookings_source_src_10001.booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_10001 @@ -59,7 +59,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 @@ -91,7 +91,7 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql index 2431233751..b3fd60e83c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0.sql @@ -163,7 +163,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -175,7 +175,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -200,7 +200,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -212,7 +212,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -224,7 +224,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -395,7 +395,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -407,7 +407,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -419,7 +419,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -432,7 +432,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -444,7 +444,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -456,7 +456,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0_optimized.sql index 0fb7a3016a..c9c233de49 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -18,7 +18,7 @@ FROM ( -- Pass Only Elements: -- ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_10001 @@ -35,7 +35,7 @@ INNER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0.sql index c9052ccd01..37220ebf25 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -157,7 +157,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -218,7 +218,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index c012c97a59..58f53057f2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -17,7 +17,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index 78bc20baf3..cbb2293251 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -145,7 +145,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -157,7 +157,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -182,7 +182,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -324,7 +324,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter @@ -336,7 +336,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter @@ -351,7 +351,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter @@ -363,7 +363,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql index fa17fe59fa..db78870137 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0.sql @@ -144,7 +144,7 @@ FROM ( , bookings_source_src_10015.booking_value AS average_booking_value , bookings_source_src_10015.booking_value AS booking_payments , bookings_source_src_10015.is_instant - , bookings_source_src_10015.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10015.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10015.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10015.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10015.ds, quarter) AS ds__quarter @@ -156,7 +156,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10015.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10015.ds) AS ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10015.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10015.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10015.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10015.paid_at, quarter) AS paid_at__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy , bookings_source_src_10015.is_instant AS booking__is_instant - , bookings_source_src_10015.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10015.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10015.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10015.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10015.ds, quarter) AS booking__ds__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10015.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10015.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10015.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10015.paid_at, quarter) AS booking__paid_at__quarter @@ -432,7 +432,7 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - users_latest_src_10021.ds AS ds__day + DATE_TRUNC(users_latest_src_10021.ds, day) AS ds__day , DATE_TRUNC(users_latest_src_10021.ds, isoweek) AS ds__week , DATE_TRUNC(users_latest_src_10021.ds, month) AS ds__month , DATE_TRUNC(users_latest_src_10021.ds, quarter) AS ds__quarter @@ -445,7 +445,7 @@ FROM ( , EXTRACT(dayofweek FROM users_latest_src_10021.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM users_latest_src_10021.ds) AS ds__extract_doy , users_latest_src_10021.home_state_latest - , users_latest_src_10021.ds AS user__ds__day + , DATE_TRUNC(users_latest_src_10021.ds, day) AS user__ds__day , DATE_TRUNC(users_latest_src_10021.ds, isoweek) AS user__ds__week , DATE_TRUNC(users_latest_src_10021.ds, month) AS user__ds__month , DATE_TRUNC(users_latest_src_10021.ds, quarter) AS user__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql index e8abbb3f87..4c0ecc75dd 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -13,7 +13,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10015 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql index eb008dd112..b236b584ab 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0.sql @@ -144,7 +144,7 @@ FROM ( , bookings_source_src_10015.booking_value AS average_booking_value , bookings_source_src_10015.booking_value AS booking_payments , bookings_source_src_10015.is_instant - , bookings_source_src_10015.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10015.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10015.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10015.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10015.ds, quarter) AS ds__quarter @@ -156,7 +156,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10015.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10015.ds) AS ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10015.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10015.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10015.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10015.paid_at, quarter) AS paid_at__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy , bookings_source_src_10015.is_instant AS booking__is_instant - , bookings_source_src_10015.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10015.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10015.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10015.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10015.ds, quarter) AS booking__ds__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10015.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10015.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10015.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10015.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10015.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql index 415ccb8d00..e2b8f6391f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -13,7 +13,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10015 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0.sql index 7896f7776d..2b4bb1e6a2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multi_join_node__plan0.sql @@ -28,7 +28,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -40,7 +40,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -52,7 +52,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -65,7 +65,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -77,7 +77,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -89,7 +89,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -122,7 +122,7 @@ LEFT OUTER JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter @@ -134,7 +134,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter @@ -149,7 +149,7 @@ LEFT OUTER JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter @@ -161,7 +161,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter @@ -196,7 +196,7 @@ LEFT OUTER JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter @@ -208,7 +208,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter @@ -223,7 +223,7 @@ LEFT OUTER JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter @@ -235,7 +235,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql index d393bdc021..3f4f8aedd6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0.sql @@ -99,7 +99,7 @@ FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT account_month_txns_src_10010.txn_count - , account_month_txns_src_10010.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -111,7 +111,7 @@ FROM ( , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_doy - , account_month_txns_src_10010.ds AS ds__day + , DATE_TRUNC(account_month_txns_src_10010.ds, day) AS ds__day , DATE_TRUNC(account_month_txns_src_10010.ds, isoweek) AS ds__week , DATE_TRUNC(account_month_txns_src_10010.ds, month) AS ds__month , DATE_TRUNC(account_month_txns_src_10010.ds, quarter) AS ds__quarter @@ -124,7 +124,7 @@ FROM ( , EXTRACT(dayofweek FROM account_month_txns_src_10010.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM account_month_txns_src_10010.ds) AS ds__extract_doy , account_month_txns_src_10010.account_month - , account_month_txns_src_10010.ds_partitioned AS account_id__ds_partitioned__day + , DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, day) AS account_id__ds_partitioned__day , DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, isoweek) AS account_id__ds_partitioned__week , DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, month) AS account_id__ds_partitioned__month , DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, quarter) AS account_id__ds_partitioned__quarter @@ -136,7 +136,7 @@ FROM ( , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_day , EXTRACT(dayofweek FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , account_month_txns_src_10010.ds AS account_id__ds__day + , DATE_TRUNC(account_month_txns_src_10010.ds, day) AS account_id__ds__day , DATE_TRUNC(account_month_txns_src_10010.ds, isoweek) AS account_id__ds__week , DATE_TRUNC(account_month_txns_src_10010.ds, month) AS account_id__ds__month , DATE_TRUNC(account_month_txns_src_10010.ds, quarter) AS account_id__ds__quarter @@ -226,7 +226,7 @@ FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT bridge_table_src_10011.extra_dim - , bridge_table_src_10011.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -239,7 +239,7 @@ FROM ( , EXTRACT(dayofweek FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_doy , bridge_table_src_10011.extra_dim AS account_id__extra_dim - , bridge_table_src_10011.ds_partitioned AS account_id__ds_partitioned__day + , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, day) AS account_id__ds_partitioned__day , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, isoweek) AS account_id__ds_partitioned__week , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, month) AS account_id__ds_partitioned__month , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, quarter) AS account_id__ds_partitioned__quarter @@ -252,7 +252,7 @@ FROM ( , EXTRACT(dayofweek FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_doy , bridge_table_src_10011.extra_dim AS bridge_account__extra_dim - , bridge_table_src_10011.ds_partitioned AS bridge_account__ds_partitioned__day + , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, day) AS bridge_account__ds_partitioned__day , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, isoweek) AS bridge_account__ds_partitioned__week , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, month) AS bridge_account__ds_partitioned__month , DATE_TRUNC(bridge_table_src_10011.ds_partitioned, quarter) AS bridge_account__ds_partitioned__quarter @@ -337,7 +337,7 @@ FROM ( SELECT customer_table_src_10013.customer_name , customer_table_src_10013.customer_atomic_weight - , customer_table_src_10013.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(customer_table_src_10013.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(customer_table_src_10013.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(customer_table_src_10013.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(customer_table_src_10013.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -351,7 +351,7 @@ FROM ( , EXTRACT(dayofyear FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_doy , customer_table_src_10013.customer_name AS customer_id__customer_name , customer_table_src_10013.customer_atomic_weight AS customer_id__customer_atomic_weight - , customer_table_src_10013.ds_partitioned AS customer_id__ds_partitioned__day + , DATE_TRUNC(customer_table_src_10013.ds_partitioned, day) AS customer_id__ds_partitioned__day , DATE_TRUNC(customer_table_src_10013.ds_partitioned, isoweek) AS customer_id__ds_partitioned__week , DATE_TRUNC(customer_table_src_10013.ds_partitioned, month) AS customer_id__ds_partitioned__month , DATE_TRUNC(customer_table_src_10013.ds_partitioned, quarter) AS customer_id__ds_partitioned__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql index c87e6307c4..a8c31cfb8a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multihop_node__plan0_optimized.sql @@ -12,7 +12,7 @@ LEFT OUTER JOIN ( -- Pass Only Elements: -- ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - bridge_table_src_10011.ds_partitioned AS ds_partitioned__day + DATE_TRUNC(bridge_table_src_10011.ds_partitioned, day) AS ds_partitioned__day , bridge_table_src_10011.account_id AS account_id , customer_table_src_10013.customer_name AS customer_id__customer_name FROM ***************************.bridge_table bridge_table_src_10011 @@ -22,14 +22,14 @@ LEFT OUTER JOIN ( ( bridge_table_src_10011.customer_id = customer_table_src_10013.customer_id ) AND ( - bridge_table_src_10011.ds_partitioned = customer_table_src_10013.ds_partitioned + DATE_TRUNC(bridge_table_src_10011.ds_partitioned, day) = DATE_TRUNC(customer_table_src_10013.ds_partitioned, day) ) ) subq_18 ON ( account_month_txns_src_10010.account_id = subq_18.account_id ) AND ( - account_month_txns_src_10010.ds_partitioned = subq_18.ds_partitioned__day + DATE_TRUNC(account_month_txns_src_10010.ds_partitioned, day) = subq_18.ds_partitioned__day ) GROUP BY account_id__customer_id__customer_name diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0.sql index a6f0b3d5fc..cbdb8edd1e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0.sql @@ -249,7 +249,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -261,7 +261,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -273,7 +273,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -286,7 +286,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -298,7 +298,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -310,7 +310,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -505,7 +505,7 @@ CROSS JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter @@ -517,7 +517,7 @@ CROSS JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter @@ -532,7 +532,7 @@ CROSS JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter @@ -544,7 +544,7 @@ CROSS JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 74dcbb71f8..134eb00d16 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -13,7 +13,7 @@ FROM ( SELECT SUM(1) AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 - WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' + WHERE DATE_TRUNC(ds, day) BETWEEN '2020-01-01' AND '2020-01-01' ) subq_17 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' @@ -26,5 +26,5 @@ CROSS JOIN ( SELECT SUM(1) AS listings FROM ***************************.dim_listings_latest listings_latest_src_10004 - WHERE created_at BETWEEN '2020-01-01' AND '2020-01-01' + WHERE DATE_TRUNC(created_at, day) BETWEEN '2020-01-01' AND '2020-01-01' ) subq_23 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0.sql index 189d129aa7..5382450973 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0.sql @@ -162,7 +162,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -186,7 +186,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -223,7 +223,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -391,7 +391,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -403,7 +403,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -415,7 +415,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -428,7 +428,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -440,7 +440,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -452,7 +452,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -632,7 +632,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -644,7 +644,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -656,7 +656,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -669,7 +669,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -681,7 +681,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -693,7 +693,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -871,7 +871,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -883,7 +883,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -895,7 +895,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -908,7 +908,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -920,7 +920,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -932,7 +932,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0_optimized.sql index e45cf8bb70..ea71adb2e4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_nested_derived_metric__plan0_optimized.sql @@ -32,7 +32,7 @@ FROM ( -- Pass Only Elements: -- ['referred_bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_25 @@ -51,7 +51,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_30 @@ -82,7 +82,7 @@ FROM ( -- Pass Only Elements: -- ['instant_bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_37 @@ -111,7 +111,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_42 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0.sql index f5af97ec20..9db0ae67f6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0_optimized.sql index 3281174961..3380608a7c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_offset_window_with_date_part__plan0_optimized.sql @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_order_by_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_order_by_node__plan0.sql index 34b763eb68..74a17119a9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_order_by_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_order_by_node__plan0.sql @@ -40,7 +40,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -52,7 +52,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -64,7 +64,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -77,7 +77,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -89,7 +89,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -101,7 +101,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_order_by_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_order_by_node__plan0_optimized.sql index efe34b261f..8e408a2b21 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_order_by_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_order_by_node__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'is_instant', 'ds__day'] SELECT - ds AS ds__day + DATE_TRUNC(ds, day) AS ds__day , is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql index edb417b214..430db26819 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0.sql @@ -101,7 +101,7 @@ FROM ( -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , id_verifications_src_10003.ds AS ds__day + , DATE_TRUNC(id_verifications_src_10003.ds, day) AS ds__day , DATE_TRUNC(id_verifications_src_10003.ds, isoweek) AS ds__week , DATE_TRUNC(id_verifications_src_10003.ds, month) AS ds__month , DATE_TRUNC(id_verifications_src_10003.ds, quarter) AS ds__quarter @@ -113,7 +113,7 @@ FROM ( , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day , EXTRACT(dayofweek FROM id_verifications_src_10003.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM id_verifications_src_10003.ds) AS ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -126,7 +126,7 @@ FROM ( , EXTRACT(dayofweek FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy , id_verifications_src_10003.verification_type - , id_verifications_src_10003.ds AS verification__ds__day + , DATE_TRUNC(id_verifications_src_10003.ds, day) AS verification__ds__day , DATE_TRUNC(id_verifications_src_10003.ds, isoweek) AS verification__ds__week , DATE_TRUNC(id_verifications_src_10003.ds, month) AS verification__ds__month , DATE_TRUNC(id_verifications_src_10003.ds, quarter) AS verification__ds__quarter @@ -138,7 +138,7 @@ FROM ( , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day , EXTRACT(dayofweek FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow , EXTRACT(dayofyear FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS verification__ds_partitioned__day + , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, day) AS verification__ds_partitioned__day , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, isoweek) AS verification__ds_partitioned__week , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, month) AS verification__ds_partitioned__month , DATE_TRUNC(id_verifications_src_10003.ds_partitioned, quarter) AS verification__ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT - users_ds_source_src_10007.ds AS ds__day + DATE_TRUNC(users_ds_source_src_10007.ds, day) AS ds__day , DATE_TRUNC(users_ds_source_src_10007.ds, isoweek) AS ds__week , DATE_TRUNC(users_ds_source_src_10007.ds, month) AS ds__month , DATE_TRUNC(users_ds_source_src_10007.ds, quarter) AS ds__quarter @@ -180,7 +180,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.ds) AS ds__extract_day , EXTRACT(dayofweek FROM users_ds_source_src_10007.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM users_ds_source_src_10007.ds) AS ds__extract_doy - , users_ds_source_src_10007.created_at AS created_at__day + , DATE_TRUNC(users_ds_source_src_10007.created_at, day) AS created_at__day , DATE_TRUNC(users_ds_source_src_10007.created_at, isoweek) AS created_at__week , DATE_TRUNC(users_ds_source_src_10007.created_at, month) AS created_at__month , DATE_TRUNC(users_ds_source_src_10007.created_at, quarter) AS created_at__quarter @@ -192,7 +192,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS created_at__extract_day , EXTRACT(dayofweek FROM users_ds_source_src_10007.created_at) AS created_at__extract_dow , EXTRACT(dayofyear FROM users_ds_source_src_10007.created_at) AS created_at__extract_doy - , users_ds_source_src_10007.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(dayofweek FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_doy , users_ds_source_src_10007.home_state - , users_ds_source_src_10007.ds AS user__ds__day + , DATE_TRUNC(users_ds_source_src_10007.ds, day) AS user__ds__day , DATE_TRUNC(users_ds_source_src_10007.ds, isoweek) AS user__ds__week , DATE_TRUNC(users_ds_source_src_10007.ds, month) AS user__ds__month , DATE_TRUNC(users_ds_source_src_10007.ds, quarter) AS user__ds__quarter @@ -217,7 +217,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.ds) AS user__ds__extract_day , EXTRACT(dayofweek FROM users_ds_source_src_10007.ds) AS user__ds__extract_dow , EXTRACT(dayofyear FROM users_ds_source_src_10007.ds) AS user__ds__extract_doy - , users_ds_source_src_10007.created_at AS user__created_at__day + , DATE_TRUNC(users_ds_source_src_10007.created_at, day) AS user__created_at__day , DATE_TRUNC(users_ds_source_src_10007.created_at, isoweek) AS user__created_at__week , DATE_TRUNC(users_ds_source_src_10007.created_at, month) AS user__created_at__month , DATE_TRUNC(users_ds_source_src_10007.created_at, quarter) AS user__created_at__quarter @@ -229,7 +229,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_day , EXTRACT(dayofweek FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_dow , EXTRACT(dayofyear FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_doy - , users_ds_source_src_10007.ds_partitioned AS user__ds_partitioned__day + , DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, day) AS user__ds_partitioned__day , DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, isoweek) AS user__ds_partitioned__week , DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, month) AS user__ds_partitioned__month , DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, quarter) AS user__ds_partitioned__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0_optimized.sql index 7deff600e3..9b2d6d25b0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_partitioned_join__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( -- Pass Only Elements: -- ['identity_verifications', 'ds_partitioned__day', 'user'] SELECT - ds_partitioned AS ds_partitioned__day + DATE_TRUNC(ds_partitioned, day) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications FROM ***************************.fct_id_verifications id_verifications_src_10003 @@ -23,7 +23,7 @@ ON ( subq_10.user = users_ds_source_src_10007.user_id ) AND ( - subq_10.ds_partitioned__day = users_ds_source_src_10007.ds_partitioned + subq_10.ds_partitioned__day = DATE_TRUNC(users_ds_source_src_10007.ds_partitioned, day) ) GROUP BY user__home_state diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node__plan0.sql index 07e622e748..f5cab4e93a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node__plan0.sql @@ -37,7 +37,7 @@ FROM ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC(accounts_source_src_10000.ds, day) AS ds__day , DATE_TRUNC(accounts_source_src_10000.ds, isoweek) AS ds__week , DATE_TRUNC(accounts_source_src_10000.ds, month) AS ds__month , DATE_TRUNC(accounts_source_src_10000.ds, quarter) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dayofweek FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC(accounts_source_src_10000.ds, day) AS account__ds__day , DATE_TRUNC(accounts_source_src_10000.ds, isoweek) AS account__ds__week , DATE_TRUNC(accounts_source_src_10000.ds, month) AS account__ds__month , DATE_TRUNC(accounts_source_src_10000.ds, quarter) AS account__ds__quarter @@ -77,7 +77,7 @@ INNER JOIN ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC(accounts_source_src_10000.ds, day) AS ds__day , DATE_TRUNC(accounts_source_src_10000.ds, isoweek) AS ds__week , DATE_TRUNC(accounts_source_src_10000.ds, month) AS ds__month , DATE_TRUNC(accounts_source_src_10000.ds, quarter) AS ds__quarter @@ -90,7 +90,7 @@ INNER JOIN ( , EXTRACT(dayofweek FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC(accounts_source_src_10000.ds, day) AS account__ds__day , DATE_TRUNC(accounts_source_src_10000.ds, isoweek) AS account__ds__week , DATE_TRUNC(accounts_source_src_10000.ds, month) AS account__ds__month , DATE_TRUNC(accounts_source_src_10000.ds, quarter) AS account__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node__plan0_optimized.sql index 060f3efacd..4e3a2a324c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node__plan0_optimized.sql @@ -37,7 +37,7 @@ FROM ( account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user - , ds AS ds__day + , DATE_TRUNC(ds, day) AS ds__day , DATE_TRUNC(ds, isoweek) AS ds__week , DATE_TRUNC(ds, month) AS ds__month , DATE_TRUNC(ds, quarter) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dayofweek FROM ds) AS ds__extract_dow , EXTRACT(dayofyear FROM ds) AS ds__extract_doy , account_type - , ds AS account__ds__day + , DATE_TRUNC(ds, day) AS account__ds__day , DATE_TRUNC(ds, isoweek) AS account__ds__week , DATE_TRUNC(ds, month) AS account__ds__month , DATE_TRUNC(ds, quarter) AS account__ds__quarter @@ -71,7 +71,7 @@ INNER JOIN ( -- Read Elements From Semantic Model 'accounts_source' -- Filter row on MIN(ds__day) SELECT - MIN(ds) AS ds__day__complete + MIN(DATE_TRUNC(ds, day)) AS ds__day__complete FROM ***************************.fct_accounts accounts_source_src_10000 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_grouping__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_grouping__plan0.sql index f13236380c..4df84d60e7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_grouping__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_grouping__plan0.sql @@ -37,7 +37,7 @@ FROM ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC(accounts_source_src_10000.ds, day) AS ds__day , DATE_TRUNC(accounts_source_src_10000.ds, isoweek) AS ds__week , DATE_TRUNC(accounts_source_src_10000.ds, month) AS ds__month , DATE_TRUNC(accounts_source_src_10000.ds, quarter) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dayofweek FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC(accounts_source_src_10000.ds, day) AS account__ds__day , DATE_TRUNC(accounts_source_src_10000.ds, isoweek) AS account__ds__week , DATE_TRUNC(accounts_source_src_10000.ds, month) AS account__ds__month , DATE_TRUNC(accounts_source_src_10000.ds, quarter) AS account__ds__quarter @@ -78,7 +78,7 @@ INNER JOIN ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC(accounts_source_src_10000.ds, day) AS ds__day , DATE_TRUNC(accounts_source_src_10000.ds, isoweek) AS ds__week , DATE_TRUNC(accounts_source_src_10000.ds, month) AS ds__month , DATE_TRUNC(accounts_source_src_10000.ds, quarter) AS ds__quarter @@ -91,7 +91,7 @@ INNER JOIN ( , EXTRACT(dayofweek FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC(accounts_source_src_10000.ds, day) AS account__ds__day , DATE_TRUNC(accounts_source_src_10000.ds, isoweek) AS account__ds__week , DATE_TRUNC(accounts_source_src_10000.ds, month) AS account__ds__month , DATE_TRUNC(accounts_source_src_10000.ds, quarter) AS account__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_grouping__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_grouping__plan0_optimized.sql index 8a36408f84..ad789550be 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_grouping__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_grouping__plan0_optimized.sql @@ -37,7 +37,7 @@ FROM ( account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user - , ds AS ds__day + , DATE_TRUNC(ds, day) AS ds__day , DATE_TRUNC(ds, isoweek) AS ds__week , DATE_TRUNC(ds, month) AS ds__month , DATE_TRUNC(ds, quarter) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dayofweek FROM ds) AS ds__extract_dow , EXTRACT(dayofyear FROM ds) AS ds__extract_doy , account_type - , ds AS account__ds__day + , DATE_TRUNC(ds, day) AS account__ds__day , DATE_TRUNC(ds, isoweek) AS account__ds__week , DATE_TRUNC(ds, month) AS account__ds__month , DATE_TRUNC(ds, quarter) AS account__ds__quarter @@ -72,7 +72,7 @@ INNER JOIN ( -- Filter row on MAX(ds__day) SELECT user_id AS user - , MAX(ds) AS ds__day__complete + , MAX(DATE_TRUNC(ds, day)) AS ds__day__complete FROM ***************************.fct_accounts accounts_source_src_10000 GROUP BY user diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_queried_group_by__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_queried_group_by__plan0.sql index eff1adbdb9..8b6a32f59f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_queried_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_queried_group_by__plan0.sql @@ -37,7 +37,7 @@ FROM ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC(accounts_source_src_10000.ds, day) AS ds__day , DATE_TRUNC(accounts_source_src_10000.ds, isoweek) AS ds__week , DATE_TRUNC(accounts_source_src_10000.ds, month) AS ds__month , DATE_TRUNC(accounts_source_src_10000.ds, quarter) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dayofweek FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC(accounts_source_src_10000.ds, day) AS account__ds__day , DATE_TRUNC(accounts_source_src_10000.ds, isoweek) AS account__ds__week , DATE_TRUNC(accounts_source_src_10000.ds, month) AS account__ds__month , DATE_TRUNC(accounts_source_src_10000.ds, quarter) AS account__ds__quarter @@ -78,7 +78,7 @@ INNER JOIN ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC(accounts_source_src_10000.ds, day) AS ds__day , DATE_TRUNC(accounts_source_src_10000.ds, isoweek) AS ds__week , DATE_TRUNC(accounts_source_src_10000.ds, month) AS ds__month , DATE_TRUNC(accounts_source_src_10000.ds, quarter) AS ds__quarter @@ -91,7 +91,7 @@ INNER JOIN ( , EXTRACT(dayofweek FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC(accounts_source_src_10000.ds, day) AS account__ds__day , DATE_TRUNC(accounts_source_src_10000.ds, isoweek) AS account__ds__week , DATE_TRUNC(accounts_source_src_10000.ds, month) AS account__ds__month , DATE_TRUNC(accounts_source_src_10000.ds, quarter) AS account__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql index 025caeebfc..c106335099 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql @@ -37,7 +37,7 @@ FROM ( account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user - , ds AS ds__day + , DATE_TRUNC(ds, day) AS ds__day , DATE_TRUNC(ds, isoweek) AS ds__week , DATE_TRUNC(ds, month) AS ds__month , DATE_TRUNC(ds, quarter) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dayofweek FROM ds) AS ds__extract_dow , EXTRACT(dayofyear FROM ds) AS ds__extract_doy , account_type - , ds AS account__ds__day + , DATE_TRUNC(ds, day) AS account__ds__day , DATE_TRUNC(ds, isoweek) AS account__ds__week , DATE_TRUNC(ds, month) AS account__ds__month , DATE_TRUNC(ds, quarter) AS account__ds__quarter @@ -72,7 +72,7 @@ INNER JOIN ( -- Filter row on MIN(ds__day) SELECT DATE_TRUNC(ds, isoweek) AS ds__week - , MIN(ds) AS ds__day__complete + , MIN(DATE_TRUNC(ds, day)) AS ds__day__complete FROM ***************************.fct_accounts accounts_source_src_10000 GROUP BY ds__week diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_simple_query_with_date_part__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_simple_query_with_date_part__plan0.sql index 031517a99c..f82614886c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_simple_query_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_simple_query_with_date_part__plan0.sql @@ -139,7 +139,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -151,7 +151,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -163,7 +163,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -176,7 +176,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -188,7 +188,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -200,7 +200,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_simple_query_with_multiple_date_parts__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_simple_query_with_multiple_date_parts__plan0.sql index ec4e2ef1e8..75bd19ad56 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_simple_query_with_multiple_date_parts__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_simple_query_with_multiple_date_parts__plan0.sql @@ -164,7 +164,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -176,7 +176,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -188,7 +188,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -201,7 +201,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -213,7 +213,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -225,7 +225,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0.sql index e01a0418ff..b77c5a1037 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_single_join_node__plan0.sql @@ -26,7 +26,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -38,7 +38,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -75,7 +75,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -87,7 +87,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -120,7 +120,7 @@ LEFT OUTER JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS ds__quarter @@ -132,7 +132,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS created_at__quarter @@ -147,7 +147,7 @@ LEFT OUTER JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__ds__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__ds__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__ds__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__ds__quarter @@ -159,7 +159,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dayofweek FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(dayofyear FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC(listings_latest_src_10004.created_at, day) AS listing__created_at__day , DATE_TRUNC(listings_latest_src_10004.created_at, isoweek) AS listing__created_at__week , DATE_TRUNC(listings_latest_src_10004.created_at, month) AS listing__created_at__month , DATE_TRUNC(listings_latest_src_10004.created_at, quarter) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_source_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_source_node__plan0.sql index 0ba3c40334..9140d1f0fd 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_source_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_source_node__plan0.sql @@ -15,7 +15,7 @@ SELECT , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -27,7 +27,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -39,7 +39,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -52,7 +52,7 @@ SELECT , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -64,7 +64,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -76,7 +76,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_source_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_source_node__plan0_optimized.sql index 3e49f05f72..53762ff4d7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_source_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/BigQuery/test_source_node__plan0_optimized.sql @@ -15,7 +15,7 @@ SELECT , booking_value AS approximate_continuous_booking_value_p99 , booking_value AS approximate_discrete_booking_value_p99 , is_instant - , ds AS ds__day + , DATE_TRUNC(ds, day) AS ds__day , DATE_TRUNC(ds, isoweek) AS ds__week , DATE_TRUNC(ds, month) AS ds__month , DATE_TRUNC(ds, quarter) AS ds__quarter @@ -27,7 +27,7 @@ SELECT , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dayofweek FROM ds) AS ds__extract_dow , EXTRACT(dayofyear FROM ds) AS ds__extract_doy - , ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(ds_partitioned, quarter) AS ds_partitioned__quarter @@ -39,7 +39,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM ds_partitioned) AS ds_partitioned__extract_doy - , paid_at AS paid_at__day + , DATE_TRUNC(paid_at, day) AS paid_at__day , DATE_TRUNC(paid_at, isoweek) AS paid_at__week , DATE_TRUNC(paid_at, month) AS paid_at__month , DATE_TRUNC(paid_at, quarter) AS paid_at__quarter @@ -52,7 +52,7 @@ SELECT , EXTRACT(dayofweek FROM paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM paid_at) AS paid_at__extract_doy , is_instant AS booking__is_instant - , ds AS booking__ds__day + , DATE_TRUNC(ds, day) AS booking__ds__day , DATE_TRUNC(ds, isoweek) AS booking__ds__week , DATE_TRUNC(ds, month) AS booking__ds__month , DATE_TRUNC(ds, quarter) AS booking__ds__quarter @@ -64,7 +64,7 @@ SELECT , EXTRACT(day FROM ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM ds) AS booking__ds__extract_doy - , ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -76,7 +76,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM ds_partitioned) AS booking__ds_partitioned__extract_doy - , paid_at AS booking__paid_at__day + , DATE_TRUNC(paid_at, day) AS booking__paid_at__day , DATE_TRUNC(paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(paid_at, month) AS booking__paid_at__month , DATE_TRUNC(paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_common_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_common_semantic_model__plan0.sql index b954d8927e..202450d6c4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_common_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_common_semantic_model__plan0.sql @@ -145,7 +145,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -157,7 +157,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -182,7 +182,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -374,7 +374,7 @@ FULL OUTER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -386,7 +386,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -398,7 +398,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -411,7 +411,7 @@ FULL OUTER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -423,7 +423,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -435,7 +435,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_common_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_common_semantic_model__plan0_optimized.sql index 6ac18252b5..552b4dc805 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_common_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_common_semantic_model__plan0_optimized.sql @@ -15,7 +15,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_12 @@ -30,11 +30,11 @@ FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) ) subq_19 ON subq_14.metric_time__day = subq_19.metric_time__day diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0.sql index b1bf877e84..2319f07e20 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node__plan0.sql @@ -39,7 +39,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -51,7 +51,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -76,7 +76,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -88,7 +88,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -100,7 +100,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -133,7 +133,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -145,7 +145,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -160,7 +160,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index 5373f3b9a9..3114cb4fc6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -169,7 +169,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -218,7 +218,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -230,7 +230,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -339,7 +339,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -351,7 +351,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -366,7 +366,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -378,7 +378,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -514,7 +514,7 @@ FROM ( -- Read Elements From Semantic Model 'views_source' SELECT 1 AS views - , views_source_src_10009.ds AS ds__day + , DATE_TRUNC('day', views_source_src_10009.ds) AS ds__day , DATE_TRUNC('week', views_source_src_10009.ds) AS ds__week , DATE_TRUNC('month', views_source_src_10009.ds) AS ds__month , DATE_TRUNC('quarter', views_source_src_10009.ds) AS ds__quarter @@ -526,7 +526,7 @@ FROM ( , EXTRACT(day FROM views_source_src_10009.ds) AS ds__extract_day , EXTRACT(dow FROM views_source_src_10009.ds) AS ds__extract_dow , EXTRACT(doy FROM views_source_src_10009.ds) AS ds__extract_doy - , views_source_src_10009.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS ds_partitioned__quarter @@ -538,7 +538,7 @@ FROM ( , EXTRACT(day FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_doy - , views_source_src_10009.ds AS view__ds__day + , DATE_TRUNC('day', views_source_src_10009.ds) AS view__ds__day , DATE_TRUNC('week', views_source_src_10009.ds) AS view__ds__week , DATE_TRUNC('month', views_source_src_10009.ds) AS view__ds__month , DATE_TRUNC('quarter', views_source_src_10009.ds) AS view__ds__quarter @@ -550,7 +550,7 @@ FROM ( , EXTRACT(day FROM views_source_src_10009.ds) AS view__ds__extract_day , EXTRACT(dow FROM views_source_src_10009.ds) AS view__ds__extract_dow , EXTRACT(doy FROM views_source_src_10009.ds) AS view__ds__extract_doy - , views_source_src_10009.ds_partitioned AS view__ds_partitioned__day + , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__day , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__week , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__month , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__quarter @@ -657,7 +657,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -669,7 +669,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -684,7 +684,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -696,7 +696,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 02295e403e..03f2aa3d7e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'ds__day', 'listing'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 @@ -49,7 +49,7 @@ INNER JOIN ( -- Pass Only Elements: -- ['views', 'ds__day', 'listing'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_10009 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql index 1bd176c115..e5b6875b78 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql @@ -42,7 +42,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -54,7 +54,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -66,7 +66,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -79,7 +79,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -91,7 +91,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -103,7 +103,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -136,7 +136,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -148,7 +148,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -163,7 +163,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -175,7 +175,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0.sql index cd879426f7..a90f9421e2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_compute_metrics_node_simple_expr__plan0.sql @@ -39,7 +39,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -51,7 +51,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -76,7 +76,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -88,7 +88,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -100,7 +100,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -133,7 +133,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -145,7 +145,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -160,7 +160,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_constrain_time_range_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_constrain_time_range_node__plan0.sql index 5b6dd99cc4..b274191665 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_constrain_time_range_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_constrain_time_range_node__plan0.sql @@ -33,7 +33,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -45,7 +45,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -57,7 +57,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -70,7 +70,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -82,7 +82,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -94,7 +94,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_constrain_time_range_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_constrain_time_range_node__plan0_optimized.sql index bfc4959615..207fa171fa 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_constrain_time_range_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_constrain_time_range_node__plan0_optimized.sql @@ -4,8 +4,8 @@ -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - ds AS ds__day - , ds AS metric_time__day + DATE_TRUNC('day', ds) AS ds__day + , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 -WHERE ds BETWEEN '2020-01-01' AND '2020-01-02' +WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0.sql index 6920a36691..3b92bc016a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric__plan0.sql @@ -59,7 +59,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -71,7 +71,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0.sql index 4080ab9420..b843616ed0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_grain_to_date__plan0.sql @@ -59,7 +59,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -71,7 +71,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0.sql index fcf74a5947..5ef2c1add0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_ds__plan0.sql @@ -56,7 +56,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -68,7 +68,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0.sql index 0143335613..5db12c7b97 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window__plan0.sql @@ -59,7 +59,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -71,7 +71,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 5cba3a3202..4a950ee81d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -101,7 +101,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -113,7 +113,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index c420ef636f..dfc97e9ec9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -9,6 +9,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time FROM ***************************.fct_revenue revenue_src_10006 -WHERE created_at BETWEEN '2000-01-01' AND '2020-01-01' +WHERE DATE_TRUNC('day', created_at) BETWEEN '2000-01-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql index 414159089b..375f61a3f6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0.sql @@ -101,7 +101,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -113,7 +113,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index e3387b51e4..c78471782b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -9,6 +9,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS trailing_2_months_revenue FROM ***************************.fct_revenue revenue_src_10006 -WHERE created_at BETWEEN '2019-12-01' AND '2020-01-01' +WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-12-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric__plan0.sql index 5b4011175d..bebcd049ee 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -379,7 +379,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -391,7 +391,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -403,7 +403,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -416,7 +416,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -428,7 +428,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -440,7 +440,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric__plan0_optimized.sql index 336e7623a6..ace6863100 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['referred_bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_13 @@ -39,7 +39,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_18 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql index d11a69936d..090069e6fb 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index 425f3c5f99..a952516e96 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_16 @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index b98d6d0f3d..73b332fea3 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index b458c826f3..e5a7e1789c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql index 9139bc862d..8461e53fc4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0_optimized.sql index 80c5452e0d..d79d809654 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_16 @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 0022a4f526..d840b06e43 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index c5d0b45b69..bbdb2547b7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 10bb6c0450..a6df144424 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -253,7 +253,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -265,7 +265,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -277,7 +277,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -290,7 +290,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -302,7 +302,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -314,7 +314,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -588,7 +588,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -600,7 +600,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -612,7 +612,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -625,7 +625,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -637,7 +637,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -649,7 +649,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index fb585a52b9..3f57ba0cbf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -22,7 +22,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_18 @@ -45,7 +45,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_26 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index 1aaa96b40a..4b45c0edc7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -253,7 +253,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -265,7 +265,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -277,7 +277,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -290,7 +290,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -302,7 +302,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -314,7 +314,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -589,7 +589,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -601,7 +601,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -613,7 +613,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -626,7 +626,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -638,7 +638,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -650,7 +650,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 966f139fe1..40dd779220 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -22,7 +22,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_18 @@ -46,7 +46,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_26 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0.sql index 3107752f3d..9c5c91984c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0.sql @@ -361,7 +361,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -373,7 +373,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -385,7 +385,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -398,7 +398,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -410,7 +410,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -422,7 +422,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0_optimized.sql index b99a126d9b..9609d10b3f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -22,9 +22,9 @@ FROM ( ***************************.fct_bookings bookings_source_src_10001 ON ( - bookings_source_src_10001.ds <= subq_14.ds + DATE_TRUNC('day', bookings_source_src_10001.ds) <= subq_14.ds ) AND ( - bookings_source_src_10001.ds > DATEADD(day, -2, subq_14.ds) + DATE_TRUNC('day', bookings_source_src_10001.ds) > DATEADD(day, -2, subq_14.ds) ) ) subq_15 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0.sql index 666e2d3376..0ea424f256 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -247,7 +247,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -259,7 +259,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -271,7 +271,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -284,7 +284,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -296,7 +296,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -308,7 +308,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index 43a78551de..5ede4be6d6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -16,7 +16,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_9 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_distinct_values__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_distinct_values__plan0.sql index 40f6785af3..86ba05d2c1 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_distinct_values__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_distinct_values__plan0.sql @@ -160,7 +160,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -184,7 +184,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -197,7 +197,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -209,7 +209,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -221,7 +221,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -330,7 +330,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -342,7 +342,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -357,7 +357,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -369,7 +369,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_node__plan0.sql index a43457fcbd..eaa8fb6dcf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_node__plan0.sql @@ -20,7 +20,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -32,7 +32,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -44,7 +44,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -57,7 +57,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -69,7 +69,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -81,7 +81,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_node__plan0.sql index a3ce23fb89..4f2da7c5cf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_node__plan0.sql @@ -26,7 +26,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -38,7 +38,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -75,7 +75,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -87,7 +87,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_node__plan0_optimized.sql index c850362ca3..98241721ca 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_node__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'ds__day'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_3 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0.sql index 70919d8caa..0022e1d7c4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -166,7 +166,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -178,7 +178,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -190,7 +190,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -203,7 +203,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -215,7 +215,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -227,7 +227,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -336,7 +336,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -348,7 +348,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -363,7 +363,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -375,7 +375,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0.sql index 6e4488a729..b8f50cd3cf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0.sql @@ -154,7 +154,7 @@ FROM ( , bookings_source_src_10015.booking_value AS average_booking_value , bookings_source_src_10015.booking_value AS booking_payments , bookings_source_src_10015.is_instant - , bookings_source_src_10015.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter @@ -166,7 +166,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter @@ -178,7 +178,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter @@ -191,7 +191,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy , bookings_source_src_10015.is_instant AS booking__is_instant - , bookings_source_src_10015.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter @@ -203,7 +203,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter @@ -215,7 +215,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0_optimized.sql index 86a2010b35..db1199fc2e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_scd_dimension__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10015 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index 9f23719b49..3a106515f6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -155,7 +155,7 @@ INNER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -167,7 +167,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -179,7 +179,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -192,7 +192,7 @@ INNER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -204,7 +204,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -216,7 +216,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index 6a4ced8cd8..d0748a2ddb 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -23,12 +23,12 @@ INNER JOIN ( -- ['booking_value', 'metric_time__day', 'listing'] -- Aggregate Measures SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) , listing_id ) subq_10 ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0.sql index 1c6b0467ff..29d0ec4e19 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -155,7 +155,7 @@ INNER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -167,7 +167,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -179,7 +179,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -192,7 +192,7 @@ INNER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -204,7 +204,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -216,7 +216,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index f5c740c47c..cc0dcc2828 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -23,12 +23,12 @@ INNER JOIN ( -- ['booking_value', 'metric_time__day', 'listing'] -- Aggregate Measures SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) , listing_id ) subq_10 ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0.sql index 2093e49b0b..457449a984 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0.sql @@ -155,7 +155,7 @@ INNER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -167,7 +167,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -179,7 +179,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -192,7 +192,7 @@ INNER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -204,7 +204,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -216,7 +216,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index 4afadfc929..26398b9d40 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -23,12 +23,12 @@ INNER JOIN ( -- ['booking_value', 'metric_time__day', 'listing'] -- Aggregate Measures SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) , listing_id ) subq_10 ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_limit_rows__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_limit_rows__plan0.sql index eb506ddf59..7fd977201f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_limit_rows__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_limit_rows__plan0.sql @@ -144,7 +144,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -156,7 +156,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_limit_rows__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_limit_rows__plan0_optimized.sql index 6db56759fc..e52871ff7c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_limit_rows__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_limit_rows__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'ds__day'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_7 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0.sql index d5688f0e2d..2ff36d921e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_local_dimension_using_local_entity__plan0.sql @@ -94,7 +94,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -106,7 +106,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -121,7 +121,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -133,7 +133,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_aggregation_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_aggregation_node__plan0.sql index dbfcb34b94..7ebbd78174 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_aggregation_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_aggregation_node__plan0.sql @@ -30,7 +30,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -42,7 +42,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -54,7 +54,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -67,7 +67,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -79,7 +79,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -91,7 +91,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql index e5349b0d17..961480acb5 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0.sql @@ -178,7 +178,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -190,7 +190,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -202,7 +202,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -215,7 +215,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -227,7 +227,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -239,7 +239,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -348,7 +348,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -360,7 +360,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -375,7 +375,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -387,7 +387,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -589,7 +589,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -601,7 +601,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -613,7 +613,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -626,7 +626,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -638,7 +638,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -650,7 +650,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -759,7 +759,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -771,7 +771,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -786,7 +786,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -798,7 +798,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -983,7 +983,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -995,7 +995,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -1007,7 +1007,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -1020,7 +1020,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -1032,7 +1032,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -1044,7 +1044,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0_optimized.sql index eb22b75d5e..bf23abb3af 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint__plan0_optimized.sql @@ -23,7 +23,7 @@ FROM ( -- Pass Only Elements: -- ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - bookings_source_src_10001.ds AS metric_time__day + DATE_TRUNC('day', bookings_source_src_10001.ds) AS metric_time__day , listings_latest_src_10004.is_lux AS listing__is_lux_latest , bookings_source_src_10001.booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_10001 @@ -59,7 +59,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 @@ -91,11 +91,11 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) ) subq_58 ON ( diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql index c11754db0d..b955d8e418 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0.sql @@ -163,7 +163,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -175,7 +175,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -200,7 +200,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -212,7 +212,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -224,7 +224,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -395,7 +395,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -407,7 +407,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -419,7 +419,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -432,7 +432,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -444,7 +444,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -456,7 +456,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0_optimized.sql index 7c202ae455..36878b678c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -18,7 +18,7 @@ FROM ( -- Pass Only Elements: -- ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_10001 @@ -35,11 +35,11 @@ INNER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) ) subq_24 ON ( diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0.sql index bd41d48bd9..58e129bcbe 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -157,7 +157,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -218,7 +218,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index c012c97a59..18094198a4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -17,7 +17,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index ecc15101fe..b9e841c10f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -145,7 +145,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -157,7 +157,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -182,7 +182,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -324,7 +324,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -336,7 +336,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -351,7 +351,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -363,7 +363,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql index 79946c1bc1..16fde28343 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0.sql @@ -144,7 +144,7 @@ FROM ( , bookings_source_src_10015.booking_value AS average_booking_value , bookings_source_src_10015.booking_value AS booking_payments , bookings_source_src_10015.is_instant - , bookings_source_src_10015.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter @@ -156,7 +156,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy , bookings_source_src_10015.is_instant AS booking__is_instant - , bookings_source_src_10015.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter @@ -432,7 +432,7 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - users_latest_src_10021.ds AS ds__day + DATE_TRUNC('day', users_latest_src_10021.ds) AS ds__day , DATE_TRUNC('week', users_latest_src_10021.ds) AS ds__week , DATE_TRUNC('month', users_latest_src_10021.ds) AS ds__month , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS ds__quarter @@ -445,7 +445,7 @@ FROM ( , EXTRACT(dow FROM users_latest_src_10021.ds) AS ds__extract_dow , EXTRACT(doy FROM users_latest_src_10021.ds) AS ds__extract_doy , users_latest_src_10021.home_state_latest - , users_latest_src_10021.ds AS user__ds__day + , DATE_TRUNC('day', users_latest_src_10021.ds) AS user__ds__day , DATE_TRUNC('week', users_latest_src_10021.ds) AS user__ds__week , DATE_TRUNC('month', users_latest_src_10021.ds) AS user__ds__month , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS user__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql index feb5ed0fdc..aa2ad14d34 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -13,7 +13,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10015 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql index 1cfb7780a7..a3e98c1218 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0.sql @@ -144,7 +144,7 @@ FROM ( , bookings_source_src_10015.booking_value AS average_booking_value , bookings_source_src_10015.booking_value AS booking_payments , bookings_source_src_10015.is_instant - , bookings_source_src_10015.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter @@ -156,7 +156,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy , bookings_source_src_10015.is_instant AS booking__is_instant - , bookings_source_src_10015.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql index f1b419a284..add7e259ab 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -13,7 +13,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10015 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0.sql index 7e38380b20..18a7c52fef 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multi_join_node__plan0.sql @@ -28,7 +28,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -40,7 +40,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -52,7 +52,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -65,7 +65,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -77,7 +77,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -89,7 +89,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -122,7 +122,7 @@ LEFT OUTER JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -134,7 +134,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -149,7 +149,7 @@ LEFT OUTER JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -161,7 +161,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -196,7 +196,7 @@ LEFT OUTER JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -208,7 +208,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -223,7 +223,7 @@ LEFT OUTER JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -235,7 +235,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql index c742d95f11..5b4b817799 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multihop_node__plan0.sql @@ -99,7 +99,7 @@ FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT account_month_txns_src_10010.txn_count - , account_month_txns_src_10010.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__quarter @@ -111,7 +111,7 @@ FROM ( , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_doy - , account_month_txns_src_10010.ds AS ds__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS ds__day , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS ds__week , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS ds__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS ds__quarter @@ -124,7 +124,7 @@ FROM ( , EXTRACT(dow FROM account_month_txns_src_10010.ds) AS ds__extract_dow , EXTRACT(doy FROM account_month_txns_src_10010.ds) AS ds__extract_doy , account_month_txns_src_10010.account_month - , account_month_txns_src_10010.ds_partitioned AS account_id__ds_partitioned__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__day , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__week , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__quarter @@ -136,7 +136,7 @@ FROM ( , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_day , EXTRACT(dow FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_dow , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , account_month_txns_src_10010.ds AS account_id__ds__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS account_id__ds__day , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS account_id__ds__week , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS account_id__ds__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS account_id__ds__quarter @@ -226,7 +226,7 @@ FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT bridge_table_src_10011.extra_dim - , bridge_table_src_10011.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__quarter @@ -239,7 +239,7 @@ FROM ( , EXTRACT(dow FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_doy , bridge_table_src_10011.extra_dim AS account_id__extra_dim - , bridge_table_src_10011.ds_partitioned AS account_id__ds_partitioned__day + , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__day , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__week , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__month , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__quarter @@ -252,7 +252,7 @@ FROM ( , EXTRACT(dow FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_dow , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_doy , bridge_table_src_10011.extra_dim AS bridge_account__extra_dim - , bridge_table_src_10011.ds_partitioned AS bridge_account__ds_partitioned__day + , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__day , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__week , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__month , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__quarter @@ -337,7 +337,7 @@ FROM ( SELECT customer_table_src_10013.customer_name , customer_table_src_10013.customer_atomic_weight - , customer_table_src_10013.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS ds_partitioned__quarter @@ -351,7 +351,7 @@ FROM ( , EXTRACT(doy FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_doy , customer_table_src_10013.customer_name AS customer_id__customer_name , customer_table_src_10013.customer_atomic_weight AS customer_id__customer_atomic_weight - , customer_table_src_10013.ds_partitioned AS customer_id__ds_partitioned__day + , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__day , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__week , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__month , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql index ba4bf14fba..8a42052413 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multihop_node__plan0_optimized.sql @@ -12,7 +12,7 @@ LEFT OUTER JOIN ( -- Pass Only Elements: -- ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - bridge_table_src_10011.ds_partitioned AS ds_partitioned__day + DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day , bridge_table_src_10011.account_id AS account_id , customer_table_src_10013.customer_name AS customer_id__customer_name FROM ***************************.bridge_table bridge_table_src_10011 @@ -22,14 +22,14 @@ LEFT OUTER JOIN ( ( bridge_table_src_10011.customer_id = customer_table_src_10013.customer_id ) AND ( - bridge_table_src_10011.ds_partitioned = customer_table_src_10013.ds_partitioned + DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) = DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) ) ) subq_18 ON ( account_month_txns_src_10010.account_id = subq_18.account_id ) AND ( - account_month_txns_src_10010.ds_partitioned = subq_18.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) = subq_18.ds_partitioned__day ) GROUP BY subq_18.customer_id__customer_name diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0.sql index 54b108dd33..df6a1ebfc8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0.sql @@ -249,7 +249,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -261,7 +261,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -273,7 +273,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -286,7 +286,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -298,7 +298,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -310,7 +310,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -505,7 +505,7 @@ CROSS JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -517,7 +517,7 @@ CROSS JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -532,7 +532,7 @@ CROSS JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -544,7 +544,7 @@ CROSS JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 74dcbb71f8..56554460d5 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -13,7 +13,7 @@ FROM ( SELECT SUM(1) AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 - WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' + WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-01' ) subq_17 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' @@ -26,5 +26,5 @@ CROSS JOIN ( SELECT SUM(1) AS listings FROM ***************************.dim_listings_latest listings_latest_src_10004 - WHERE created_at BETWEEN '2020-01-01' AND '2020-01-01' + WHERE DATE_TRUNC('day', created_at) BETWEEN '2020-01-01' AND '2020-01-01' ) subq_23 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0.sql index a716977aaf..bd98232377 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0.sql @@ -162,7 +162,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -186,7 +186,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -223,7 +223,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -391,7 +391,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -403,7 +403,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -415,7 +415,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -428,7 +428,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -440,7 +440,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -452,7 +452,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -632,7 +632,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -644,7 +644,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -656,7 +656,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -669,7 +669,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -681,7 +681,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -693,7 +693,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -871,7 +871,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -883,7 +883,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -895,7 +895,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -908,7 +908,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -920,7 +920,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -932,7 +932,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0_optimized.sql index e45cf8bb70..519c4b6ea5 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_nested_derived_metric__plan0_optimized.sql @@ -32,7 +32,7 @@ FROM ( -- Pass Only Elements: -- ['referred_bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_25 @@ -51,7 +51,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_30 @@ -82,7 +82,7 @@ FROM ( -- Pass Only Elements: -- ['instant_bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_37 @@ -111,7 +111,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_42 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0.sql index 68e1d3302c..1d6baffd15 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0_optimized.sql index d1a408e031..cbb1d95f41 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_offset_window_with_date_part__plan0_optimized.sql @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_order_by_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_order_by_node__plan0.sql index d6632b499f..5aaceec9da 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_order_by_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_order_by_node__plan0.sql @@ -40,7 +40,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -52,7 +52,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -64,7 +64,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -77,7 +77,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -89,7 +89,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -101,7 +101,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_order_by_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_order_by_node__plan0_optimized.sql index efe34b261f..b0e38b1d22 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_order_by_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_order_by_node__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'is_instant', 'ds__day'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql index 44cff4ab94..778bddf502 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0.sql @@ -101,7 +101,7 @@ FROM ( -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , id_verifications_src_10003.ds AS ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter @@ -113,7 +113,7 @@ FROM ( , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter @@ -126,7 +126,7 @@ FROM ( , EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy , id_verifications_src_10003.verification_type - , id_verifications_src_10003.ds AS verification__ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter @@ -138,7 +138,7 @@ FROM ( , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS verification__ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT - users_ds_source_src_10007.ds AS ds__day + DATE_TRUNC('day', users_ds_source_src_10007.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS ds__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS ds__quarter @@ -180,7 +180,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.ds) AS ds__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.ds) AS ds__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS ds__extract_doy - , users_ds_source_src_10007.created_at AS created_at__day + , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS created_at__day , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS created_at__week , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS created_at__month , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS created_at__quarter @@ -192,7 +192,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS created_at__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.created_at) AS created_at__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS created_at__extract_doy - , users_ds_source_src_10007.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(dow FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_doy , users_ds_source_src_10007.home_state - , users_ds_source_src_10007.ds AS user__ds__day + , DATE_TRUNC('day', users_ds_source_src_10007.ds) AS user__ds__day , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS user__ds__week , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS user__ds__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS user__ds__quarter @@ -217,7 +217,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.ds) AS user__ds__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.ds) AS user__ds__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS user__ds__extract_doy - , users_ds_source_src_10007.created_at AS user__created_at__day + , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS user__created_at__day , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS user__created_at__week , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS user__created_at__month , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS user__created_at__quarter @@ -229,7 +229,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_doy - , users_ds_source_src_10007.ds_partitioned AS user__ds_partitioned__day + , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__day , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__week , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0_optimized.sql index 66ea172ae7..c15982d861 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_partitioned_join__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( -- Pass Only Elements: -- ['identity_verifications', 'ds_partitioned__day', 'user'] SELECT - ds_partitioned AS ds_partitioned__day + DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications FROM ***************************.fct_id_verifications id_verifications_src_10003 @@ -23,7 +23,7 @@ ON ( subq_10.user = users_ds_source_src_10007.user_id ) AND ( - subq_10.ds_partitioned__day = users_ds_source_src_10007.ds_partitioned + subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) ) GROUP BY users_ds_source_src_10007.home_state diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node__plan0.sql index 33fc914795..6c9249001c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node__plan0.sql @@ -37,7 +37,7 @@ FROM ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter @@ -77,7 +77,7 @@ INNER JOIN ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -90,7 +90,7 @@ INNER JOIN ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node__plan0_optimized.sql index d90abbd294..c35f358f2d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node__plan0_optimized.sql @@ -37,7 +37,7 @@ FROM ( account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy , account_type - , ds AS account__ds__day + , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week , DATE_TRUNC('month', ds) AS account__ds__month , DATE_TRUNC('quarter', ds) AS account__ds__quarter @@ -71,7 +71,7 @@ INNER JOIN ( -- Read Elements From Semantic Model 'accounts_source' -- Filter row on MIN(ds__day) SELECT - MIN(ds) AS ds__day__complete + MIN(DATE_TRUNC('day', ds)) AS ds__day__complete FROM ***************************.fct_accounts accounts_source_src_10000 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_grouping__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_grouping__plan0.sql index dc98b44d95..c98bf2362f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_grouping__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_grouping__plan0.sql @@ -37,7 +37,7 @@ FROM ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter @@ -78,7 +78,7 @@ INNER JOIN ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -91,7 +91,7 @@ INNER JOIN ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_grouping__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_grouping__plan0_optimized.sql index d723157d2a..bb14649634 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_grouping__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_grouping__plan0_optimized.sql @@ -37,7 +37,7 @@ FROM ( account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy , account_type - , ds AS account__ds__day + , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week , DATE_TRUNC('month', ds) AS account__ds__month , DATE_TRUNC('quarter', ds) AS account__ds__quarter @@ -72,7 +72,7 @@ INNER JOIN ( -- Filter row on MAX(ds__day) SELECT user_id AS user - , MAX(ds) AS ds__day__complete + , MAX(DATE_TRUNC('day', ds)) AS ds__day__complete FROM ***************************.fct_accounts accounts_source_src_10000 GROUP BY user_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_queried_group_by__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_queried_group_by__plan0.sql index 95274f2863..d42a779e8d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_queried_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_queried_group_by__plan0.sql @@ -37,7 +37,7 @@ FROM ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter @@ -78,7 +78,7 @@ INNER JOIN ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -91,7 +91,7 @@ INNER JOIN ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql index e0c877bdf1..89c29c7a7f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql @@ -37,7 +37,7 @@ FROM ( account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy , account_type - , ds AS account__ds__day + , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week , DATE_TRUNC('month', ds) AS account__ds__month , DATE_TRUNC('quarter', ds) AS account__ds__quarter @@ -72,7 +72,7 @@ INNER JOIN ( -- Filter row on MIN(ds__day) SELECT DATE_TRUNC('week', ds) AS ds__week - , MIN(ds) AS ds__day__complete + , MIN(DATE_TRUNC('day', ds)) AS ds__day__complete FROM ***************************.fct_accounts accounts_source_src_10000 GROUP BY DATE_TRUNC('week', ds) diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_simple_query_with_date_part__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_simple_query_with_date_part__plan0.sql index 3869c341c5..460694cf59 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_simple_query_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_simple_query_with_date_part__plan0.sql @@ -139,7 +139,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -151,7 +151,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -163,7 +163,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -176,7 +176,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -188,7 +188,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -200,7 +200,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_simple_query_with_multiple_date_parts__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_simple_query_with_multiple_date_parts__plan0.sql index b1321ec748..078ba0df0c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_simple_query_with_multiple_date_parts__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_simple_query_with_multiple_date_parts__plan0.sql @@ -164,7 +164,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -176,7 +176,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -188,7 +188,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -201,7 +201,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -213,7 +213,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -225,7 +225,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0.sql index 9c6e0a2676..7e054cfaa7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_single_join_node__plan0.sql @@ -26,7 +26,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -38,7 +38,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -75,7 +75,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -87,7 +87,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -120,7 +120,7 @@ LEFT OUTER JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -132,7 +132,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -147,7 +147,7 @@ LEFT OUTER JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -159,7 +159,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_source_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_source_node__plan0.sql index b9ae7f84a4..b2741d3532 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_source_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_source_node__plan0.sql @@ -15,7 +15,7 @@ SELECT , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -27,7 +27,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -39,7 +39,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -52,7 +52,7 @@ SELECT , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -64,7 +64,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -76,7 +76,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_source_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_source_node__plan0_optimized.sql index d1560d9ab0..ba6c6f95c0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_source_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Databricks/test_source_node__plan0_optimized.sql @@ -15,7 +15,7 @@ SELECT , booking_value AS approximate_continuous_booking_value_p99 , booking_value AS approximate_discrete_booking_value_p99 , is_instant - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -27,7 +27,7 @@ SELECT , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy - , ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS ds_partitioned__quarter @@ -39,7 +39,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS ds_partitioned__extract_doy - , paid_at AS paid_at__day + , DATE_TRUNC('day', paid_at) AS paid_at__day , DATE_TRUNC('week', paid_at) AS paid_at__week , DATE_TRUNC('month', paid_at) AS paid_at__month , DATE_TRUNC('quarter', paid_at) AS paid_at__quarter @@ -52,7 +52,7 @@ SELECT , EXTRACT(dow FROM paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS paid_at__extract_doy , is_instant AS booking__is_instant - , ds AS booking__ds__day + , DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('week', ds) AS booking__ds__week , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('quarter', ds) AS booking__ds__quarter @@ -64,7 +64,7 @@ SELECT , EXTRACT(day FROM ds) AS booking__ds__extract_day , EXTRACT(dow FROM ds) AS booking__ds__extract_dow , EXTRACT(doy FROM ds) AS booking__ds__extract_doy - , ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS booking__ds_partitioned__quarter @@ -76,7 +76,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS booking__ds_partitioned__extract_doy - , paid_at AS booking__paid_at__day + , DATE_TRUNC('day', paid_at) AS booking__paid_at__day , DATE_TRUNC('week', paid_at) AS booking__paid_at__week , DATE_TRUNC('month', paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_common_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_common_semantic_model__plan0.sql index b954d8927e..202450d6c4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_common_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_common_semantic_model__plan0.sql @@ -145,7 +145,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -157,7 +157,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -182,7 +182,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -374,7 +374,7 @@ FULL OUTER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -386,7 +386,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -398,7 +398,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -411,7 +411,7 @@ FULL OUTER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -423,7 +423,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -435,7 +435,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_common_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_common_semantic_model__plan0_optimized.sql index 6ac18252b5..552b4dc805 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_common_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_common_semantic_model__plan0_optimized.sql @@ -15,7 +15,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_12 @@ -30,11 +30,11 @@ FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) ) subq_19 ON subq_14.metric_time__day = subq_19.metric_time__day diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0.sql index b1bf877e84..2319f07e20 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node__plan0.sql @@ -39,7 +39,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -51,7 +51,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -76,7 +76,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -88,7 +88,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -100,7 +100,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -133,7 +133,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -145,7 +145,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -160,7 +160,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index 5373f3b9a9..3114cb4fc6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -169,7 +169,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -218,7 +218,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -230,7 +230,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -339,7 +339,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -351,7 +351,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -366,7 +366,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -378,7 +378,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -514,7 +514,7 @@ FROM ( -- Read Elements From Semantic Model 'views_source' SELECT 1 AS views - , views_source_src_10009.ds AS ds__day + , DATE_TRUNC('day', views_source_src_10009.ds) AS ds__day , DATE_TRUNC('week', views_source_src_10009.ds) AS ds__week , DATE_TRUNC('month', views_source_src_10009.ds) AS ds__month , DATE_TRUNC('quarter', views_source_src_10009.ds) AS ds__quarter @@ -526,7 +526,7 @@ FROM ( , EXTRACT(day FROM views_source_src_10009.ds) AS ds__extract_day , EXTRACT(dow FROM views_source_src_10009.ds) AS ds__extract_dow , EXTRACT(doy FROM views_source_src_10009.ds) AS ds__extract_doy - , views_source_src_10009.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS ds_partitioned__quarter @@ -538,7 +538,7 @@ FROM ( , EXTRACT(day FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_doy - , views_source_src_10009.ds AS view__ds__day + , DATE_TRUNC('day', views_source_src_10009.ds) AS view__ds__day , DATE_TRUNC('week', views_source_src_10009.ds) AS view__ds__week , DATE_TRUNC('month', views_source_src_10009.ds) AS view__ds__month , DATE_TRUNC('quarter', views_source_src_10009.ds) AS view__ds__quarter @@ -550,7 +550,7 @@ FROM ( , EXTRACT(day FROM views_source_src_10009.ds) AS view__ds__extract_day , EXTRACT(dow FROM views_source_src_10009.ds) AS view__ds__extract_dow , EXTRACT(doy FROM views_source_src_10009.ds) AS view__ds__extract_doy - , views_source_src_10009.ds_partitioned AS view__ds_partitioned__day + , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__day , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__week , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__month , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__quarter @@ -657,7 +657,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -669,7 +669,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -684,7 +684,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -696,7 +696,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 02295e403e..03f2aa3d7e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'ds__day', 'listing'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 @@ -49,7 +49,7 @@ INNER JOIN ( -- Pass Only Elements: -- ['views', 'ds__day', 'listing'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_10009 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql index 1bd176c115..e5b6875b78 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql @@ -42,7 +42,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -54,7 +54,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -66,7 +66,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -79,7 +79,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -91,7 +91,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -103,7 +103,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -136,7 +136,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -148,7 +148,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -163,7 +163,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -175,7 +175,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0.sql index cd879426f7..a90f9421e2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_compute_metrics_node_simple_expr__plan0.sql @@ -39,7 +39,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -51,7 +51,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -76,7 +76,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -88,7 +88,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -100,7 +100,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -133,7 +133,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -145,7 +145,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -160,7 +160,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_constrain_time_range_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_constrain_time_range_node__plan0.sql index 5b6dd99cc4..b274191665 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_constrain_time_range_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_constrain_time_range_node__plan0.sql @@ -33,7 +33,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -45,7 +45,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -57,7 +57,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -70,7 +70,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -82,7 +82,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -94,7 +94,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_constrain_time_range_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_constrain_time_range_node__plan0_optimized.sql index bfc4959615..207fa171fa 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_constrain_time_range_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_constrain_time_range_node__plan0_optimized.sql @@ -4,8 +4,8 @@ -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - ds AS ds__day - , ds AS metric_time__day + DATE_TRUNC('day', ds) AS ds__day + , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 -WHERE ds BETWEEN '2020-01-01' AND '2020-01-02' +WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0.sql index 6920a36691..3b92bc016a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric__plan0.sql @@ -59,7 +59,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -71,7 +71,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0.sql index 4080ab9420..b843616ed0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_grain_to_date__plan0.sql @@ -59,7 +59,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -71,7 +71,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0.sql index fcf74a5947..5ef2c1add0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_ds__plan0.sql @@ -56,7 +56,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -68,7 +68,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0.sql index 0143335613..5db12c7b97 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window__plan0.sql @@ -59,7 +59,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -71,7 +71,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 5cba3a3202..4a950ee81d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -101,7 +101,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -113,7 +113,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index c420ef636f..dfc97e9ec9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -9,6 +9,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time FROM ***************************.fct_revenue revenue_src_10006 -WHERE created_at BETWEEN '2000-01-01' AND '2020-01-01' +WHERE DATE_TRUNC('day', created_at) BETWEEN '2000-01-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0.sql index 414159089b..375f61a3f6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0.sql @@ -101,7 +101,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -113,7 +113,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index e3387b51e4..c78471782b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -9,6 +9,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS trailing_2_months_revenue FROM ***************************.fct_revenue revenue_src_10006 -WHERE created_at BETWEEN '2019-12-01' AND '2020-01-01' +WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-12-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0.sql index 5b4011175d..bebcd049ee 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -379,7 +379,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -391,7 +391,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -403,7 +403,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -416,7 +416,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -428,7 +428,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -440,7 +440,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0_optimized.sql index 336e7623a6..ace6863100 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['referred_bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_13 @@ -39,7 +39,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_18 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0.sql index d11a69936d..090069e6fb 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index 425f3c5f99..a952516e96 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_16 @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index b98d6d0f3d..73b332fea3 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index b458c826f3..e5a7e1789c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0.sql index 38aeec72e9..d7024f5fc0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0_optimized.sql index 28b07ca0e2..612203ca28 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_16 @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 0ad6211336..951ca49251 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index db9eaf374e..db8895099d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index c987150223..a80def1292 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -253,7 +253,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -265,7 +265,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -277,7 +277,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -290,7 +290,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -302,7 +302,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -314,7 +314,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -588,7 +588,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -600,7 +600,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -612,7 +612,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -625,7 +625,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -637,7 +637,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -649,7 +649,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index e239a53fef..a01918dbd2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -22,7 +22,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_18 @@ -45,7 +45,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_26 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index cddee48ddb..db7541db6e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -253,7 +253,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -265,7 +265,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -277,7 +277,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -290,7 +290,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -302,7 +302,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -314,7 +314,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -589,7 +589,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -601,7 +601,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -613,7 +613,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -626,7 +626,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -638,7 +638,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -650,7 +650,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index f4b9c2a35c..570c54fab1 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -22,7 +22,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_18 @@ -46,7 +46,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_26 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0.sql index 94cf44278b..69d1bf6182 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0.sql @@ -361,7 +361,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -373,7 +373,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -385,7 +385,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -398,7 +398,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -410,7 +410,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -422,7 +422,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0_optimized.sql index 1b96977064..e597cdaf7a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -22,9 +22,9 @@ FROM ( ***************************.fct_bookings bookings_source_src_10001 ON ( - bookings_source_src_10001.ds <= subq_14.ds + DATE_TRUNC('day', bookings_source_src_10001.ds) <= subq_14.ds ) AND ( - bookings_source_src_10001.ds > subq_14.ds - INTERVAL 2 day + DATE_TRUNC('day', bookings_source_src_10001.ds) > subq_14.ds - INTERVAL 2 day ) ) subq_15 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0.sql index 6b4f9e31f9..3a6fa7f357 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -247,7 +247,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -259,7 +259,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -271,7 +271,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -284,7 +284,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -296,7 +296,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -308,7 +308,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index b5a8855b9c..198cfe6766 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -16,7 +16,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_9 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0.sql index 40f6785af3..86ba05d2c1 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_distinct_values__plan0.sql @@ -160,7 +160,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -184,7 +184,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -197,7 +197,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -209,7 +209,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -221,7 +221,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -330,7 +330,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -342,7 +342,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -357,7 +357,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -369,7 +369,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_node__plan0.sql index a43457fcbd..eaa8fb6dcf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_node__plan0.sql @@ -20,7 +20,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -32,7 +32,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -44,7 +44,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -57,7 +57,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -69,7 +69,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -81,7 +81,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_node__plan0.sql index a3ce23fb89..4f2da7c5cf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_node__plan0.sql @@ -26,7 +26,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -38,7 +38,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -75,7 +75,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -87,7 +87,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_node__plan0_optimized.sql index c850362ca3..98241721ca 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_node__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'ds__day'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_3 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0.sql index 70919d8caa..0022e1d7c4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -166,7 +166,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -178,7 +178,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -190,7 +190,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -203,7 +203,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -215,7 +215,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -227,7 +227,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -336,7 +336,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -348,7 +348,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -363,7 +363,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -375,7 +375,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0.sql index 6e4488a729..b8f50cd3cf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0.sql @@ -154,7 +154,7 @@ FROM ( , bookings_source_src_10015.booking_value AS average_booking_value , bookings_source_src_10015.booking_value AS booking_payments , bookings_source_src_10015.is_instant - , bookings_source_src_10015.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter @@ -166,7 +166,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter @@ -178,7 +178,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter @@ -191,7 +191,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy , bookings_source_src_10015.is_instant AS booking__is_instant - , bookings_source_src_10015.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter @@ -203,7 +203,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter @@ -215,7 +215,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0_optimized.sql index 86a2010b35..db1199fc2e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_scd_dimension__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10015 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index 9f23719b49..3a106515f6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -155,7 +155,7 @@ INNER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -167,7 +167,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -179,7 +179,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -192,7 +192,7 @@ INNER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -204,7 +204,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -216,7 +216,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index 6a4ced8cd8..d0748a2ddb 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -23,12 +23,12 @@ INNER JOIN ( -- ['booking_value', 'metric_time__day', 'listing'] -- Aggregate Measures SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) , listing_id ) subq_10 ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_window__plan0.sql index 406b83cae3..e9f2d6773c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -155,7 +155,7 @@ INNER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -167,7 +167,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -179,7 +179,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -192,7 +192,7 @@ INNER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -204,7 +204,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -216,7 +216,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index 4a9399b1f2..913f897dc4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -23,12 +23,12 @@ INNER JOIN ( -- ['booking_value', 'metric_time__day', 'listing'] -- Aggregate Measures SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) , listing_id ) subq_10 ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_without_offset__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_without_offset__plan0.sql index 2093e49b0b..457449a984 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_without_offset__plan0.sql @@ -155,7 +155,7 @@ INNER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -167,7 +167,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -179,7 +179,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -192,7 +192,7 @@ INNER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -204,7 +204,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -216,7 +216,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index 4afadfc929..26398b9d40 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -23,12 +23,12 @@ INNER JOIN ( -- ['booking_value', 'metric_time__day', 'listing'] -- Aggregate Measures SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) , listing_id ) subq_10 ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_limit_rows__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_limit_rows__plan0.sql index eb506ddf59..7fd977201f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_limit_rows__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_limit_rows__plan0.sql @@ -144,7 +144,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -156,7 +156,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_limit_rows__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_limit_rows__plan0_optimized.sql index 6db56759fc..e52871ff7c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_limit_rows__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_limit_rows__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'ds__day'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_7 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0.sql index d5688f0e2d..2ff36d921e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_local_dimension_using_local_entity__plan0.sql @@ -94,7 +94,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -106,7 +106,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -121,7 +121,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -133,7 +133,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_aggregation_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_aggregation_node__plan0.sql index dbfcb34b94..7ebbd78174 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_aggregation_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_aggregation_node__plan0.sql @@ -30,7 +30,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -42,7 +42,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -54,7 +54,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -67,7 +67,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -79,7 +79,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -91,7 +91,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0.sql index e5349b0d17..961480acb5 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0.sql @@ -178,7 +178,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -190,7 +190,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -202,7 +202,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -215,7 +215,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -227,7 +227,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -239,7 +239,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -348,7 +348,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -360,7 +360,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -375,7 +375,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -387,7 +387,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -589,7 +589,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -601,7 +601,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -613,7 +613,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -626,7 +626,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -638,7 +638,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -650,7 +650,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -759,7 +759,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -771,7 +771,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -786,7 +786,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -798,7 +798,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -983,7 +983,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -995,7 +995,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -1007,7 +1007,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -1020,7 +1020,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -1032,7 +1032,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -1044,7 +1044,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0_optimized.sql index eb22b75d5e..bf23abb3af 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint__plan0_optimized.sql @@ -23,7 +23,7 @@ FROM ( -- Pass Only Elements: -- ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - bookings_source_src_10001.ds AS metric_time__day + DATE_TRUNC('day', bookings_source_src_10001.ds) AS metric_time__day , listings_latest_src_10004.is_lux AS listing__is_lux_latest , bookings_source_src_10001.booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_10001 @@ -59,7 +59,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 @@ -91,11 +91,11 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) ) subq_58 ON ( diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0.sql index c11754db0d..b955d8e418 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0.sql @@ -163,7 +163,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -175,7 +175,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -200,7 +200,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -212,7 +212,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -224,7 +224,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -395,7 +395,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -407,7 +407,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -419,7 +419,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -432,7 +432,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -444,7 +444,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -456,7 +456,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0_optimized.sql index 7c202ae455..36878b678c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -18,7 +18,7 @@ FROM ( -- Pass Only Elements: -- ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_10001 @@ -35,11 +35,11 @@ INNER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) ) subq_24 ON ( diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0.sql index bd41d48bd9..58e129bcbe 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -157,7 +157,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -218,7 +218,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index c012c97a59..18094198a4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -17,7 +17,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index ecc15101fe..b9e841c10f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -145,7 +145,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -157,7 +157,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -182,7 +182,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -324,7 +324,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -336,7 +336,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -351,7 +351,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -363,7 +363,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0.sql index 79946c1bc1..16fde28343 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0.sql @@ -144,7 +144,7 @@ FROM ( , bookings_source_src_10015.booking_value AS average_booking_value , bookings_source_src_10015.booking_value AS booking_payments , bookings_source_src_10015.is_instant - , bookings_source_src_10015.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter @@ -156,7 +156,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy , bookings_source_src_10015.is_instant AS booking__is_instant - , bookings_source_src_10015.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter @@ -432,7 +432,7 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - users_latest_src_10021.ds AS ds__day + DATE_TRUNC('day', users_latest_src_10021.ds) AS ds__day , DATE_TRUNC('week', users_latest_src_10021.ds) AS ds__week , DATE_TRUNC('month', users_latest_src_10021.ds) AS ds__month , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS ds__quarter @@ -445,7 +445,7 @@ FROM ( , EXTRACT(dow FROM users_latest_src_10021.ds) AS ds__extract_dow , EXTRACT(doy FROM users_latest_src_10021.ds) AS ds__extract_doy , users_latest_src_10021.home_state_latest - , users_latest_src_10021.ds AS user__ds__day + , DATE_TRUNC('day', users_latest_src_10021.ds) AS user__ds__day , DATE_TRUNC('week', users_latest_src_10021.ds) AS user__ds__week , DATE_TRUNC('month', users_latest_src_10021.ds) AS user__ds__month , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS user__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0_optimized.sql index feb5ed0fdc..aa2ad14d34 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -13,7 +13,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10015 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0.sql index 1cfb7780a7..a3e98c1218 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0.sql @@ -144,7 +144,7 @@ FROM ( , bookings_source_src_10015.booking_value AS average_booking_value , bookings_source_src_10015.booking_value AS booking_payments , bookings_source_src_10015.is_instant - , bookings_source_src_10015.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter @@ -156,7 +156,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy , bookings_source_src_10015.is_instant AS booking__is_instant - , bookings_source_src_10015.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0_optimized.sql index f1b419a284..add7e259ab 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -13,7 +13,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10015 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0.sql index 7e38380b20..18a7c52fef 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multi_join_node__plan0.sql @@ -28,7 +28,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -40,7 +40,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -52,7 +52,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -65,7 +65,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -77,7 +77,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -89,7 +89,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -122,7 +122,7 @@ LEFT OUTER JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -134,7 +134,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -149,7 +149,7 @@ LEFT OUTER JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -161,7 +161,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -196,7 +196,7 @@ LEFT OUTER JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -208,7 +208,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -223,7 +223,7 @@ LEFT OUTER JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -235,7 +235,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0.sql index c742d95f11..5b4b817799 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0.sql @@ -99,7 +99,7 @@ FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT account_month_txns_src_10010.txn_count - , account_month_txns_src_10010.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__quarter @@ -111,7 +111,7 @@ FROM ( , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_doy - , account_month_txns_src_10010.ds AS ds__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS ds__day , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS ds__week , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS ds__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS ds__quarter @@ -124,7 +124,7 @@ FROM ( , EXTRACT(dow FROM account_month_txns_src_10010.ds) AS ds__extract_dow , EXTRACT(doy FROM account_month_txns_src_10010.ds) AS ds__extract_doy , account_month_txns_src_10010.account_month - , account_month_txns_src_10010.ds_partitioned AS account_id__ds_partitioned__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__day , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__week , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__quarter @@ -136,7 +136,7 @@ FROM ( , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_day , EXTRACT(dow FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_dow , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , account_month_txns_src_10010.ds AS account_id__ds__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS account_id__ds__day , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS account_id__ds__week , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS account_id__ds__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS account_id__ds__quarter @@ -226,7 +226,7 @@ FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT bridge_table_src_10011.extra_dim - , bridge_table_src_10011.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__quarter @@ -239,7 +239,7 @@ FROM ( , EXTRACT(dow FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_doy , bridge_table_src_10011.extra_dim AS account_id__extra_dim - , bridge_table_src_10011.ds_partitioned AS account_id__ds_partitioned__day + , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__day , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__week , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__month , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__quarter @@ -252,7 +252,7 @@ FROM ( , EXTRACT(dow FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_dow , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_doy , bridge_table_src_10011.extra_dim AS bridge_account__extra_dim - , bridge_table_src_10011.ds_partitioned AS bridge_account__ds_partitioned__day + , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__day , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__week , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__month , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__quarter @@ -337,7 +337,7 @@ FROM ( SELECT customer_table_src_10013.customer_name , customer_table_src_10013.customer_atomic_weight - , customer_table_src_10013.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS ds_partitioned__quarter @@ -351,7 +351,7 @@ FROM ( , EXTRACT(doy FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_doy , customer_table_src_10013.customer_name AS customer_id__customer_name , customer_table_src_10013.customer_atomic_weight AS customer_id__customer_atomic_weight - , customer_table_src_10013.ds_partitioned AS customer_id__ds_partitioned__day + , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__day , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__week , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__month , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0_optimized.sql index ba4bf14fba..8a42052413 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multihop_node__plan0_optimized.sql @@ -12,7 +12,7 @@ LEFT OUTER JOIN ( -- Pass Only Elements: -- ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - bridge_table_src_10011.ds_partitioned AS ds_partitioned__day + DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day , bridge_table_src_10011.account_id AS account_id , customer_table_src_10013.customer_name AS customer_id__customer_name FROM ***************************.bridge_table bridge_table_src_10011 @@ -22,14 +22,14 @@ LEFT OUTER JOIN ( ( bridge_table_src_10011.customer_id = customer_table_src_10013.customer_id ) AND ( - bridge_table_src_10011.ds_partitioned = customer_table_src_10013.ds_partitioned + DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) = DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) ) ) subq_18 ON ( account_month_txns_src_10010.account_id = subq_18.account_id ) AND ( - account_month_txns_src_10010.ds_partitioned = subq_18.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) = subq_18.ds_partitioned__day ) GROUP BY subq_18.customer_id__customer_name diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0.sql index 54b108dd33..df6a1ebfc8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0.sql @@ -249,7 +249,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -261,7 +261,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -273,7 +273,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -286,7 +286,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -298,7 +298,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -310,7 +310,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -505,7 +505,7 @@ CROSS JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -517,7 +517,7 @@ CROSS JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -532,7 +532,7 @@ CROSS JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -544,7 +544,7 @@ CROSS JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 74dcbb71f8..56554460d5 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -13,7 +13,7 @@ FROM ( SELECT SUM(1) AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 - WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' + WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-01' ) subq_17 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' @@ -26,5 +26,5 @@ CROSS JOIN ( SELECT SUM(1) AS listings FROM ***************************.dim_listings_latest listings_latest_src_10004 - WHERE created_at BETWEEN '2020-01-01' AND '2020-01-01' + WHERE DATE_TRUNC('day', created_at) BETWEEN '2020-01-01' AND '2020-01-01' ) subq_23 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0.sql index a716977aaf..bd98232377 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0.sql @@ -162,7 +162,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -186,7 +186,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -223,7 +223,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -391,7 +391,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -403,7 +403,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -415,7 +415,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -428,7 +428,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -440,7 +440,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -452,7 +452,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -632,7 +632,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -644,7 +644,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -656,7 +656,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -669,7 +669,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -681,7 +681,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -693,7 +693,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -871,7 +871,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -883,7 +883,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -895,7 +895,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -908,7 +908,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -920,7 +920,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -932,7 +932,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0_optimized.sql index e45cf8bb70..519c4b6ea5 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_nested_derived_metric__plan0_optimized.sql @@ -32,7 +32,7 @@ FROM ( -- Pass Only Elements: -- ['referred_bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_25 @@ -51,7 +51,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_30 @@ -82,7 +82,7 @@ FROM ( -- Pass Only Elements: -- ['instant_bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_37 @@ -111,7 +111,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_42 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0.sql index a65895e8b1..d98921abb2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0_optimized.sql index 5f6ec1ee79..76c25bc3ac 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0_optimized.sql @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_order_by_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_order_by_node__plan0.sql index d6632b499f..5aaceec9da 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_order_by_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_order_by_node__plan0.sql @@ -40,7 +40,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -52,7 +52,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -64,7 +64,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -77,7 +77,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -89,7 +89,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -101,7 +101,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_order_by_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_order_by_node__plan0_optimized.sql index efe34b261f..b0e38b1d22 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_order_by_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_order_by_node__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'is_instant', 'ds__day'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0.sql index 44cff4ab94..778bddf502 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0.sql @@ -101,7 +101,7 @@ FROM ( -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , id_verifications_src_10003.ds AS ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter @@ -113,7 +113,7 @@ FROM ( , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter @@ -126,7 +126,7 @@ FROM ( , EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy , id_verifications_src_10003.verification_type - , id_verifications_src_10003.ds AS verification__ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter @@ -138,7 +138,7 @@ FROM ( , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS verification__ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT - users_ds_source_src_10007.ds AS ds__day + DATE_TRUNC('day', users_ds_source_src_10007.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS ds__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS ds__quarter @@ -180,7 +180,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.ds) AS ds__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.ds) AS ds__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS ds__extract_doy - , users_ds_source_src_10007.created_at AS created_at__day + , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS created_at__day , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS created_at__week , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS created_at__month , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS created_at__quarter @@ -192,7 +192,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS created_at__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.created_at) AS created_at__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS created_at__extract_doy - , users_ds_source_src_10007.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(dow FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_doy , users_ds_source_src_10007.home_state - , users_ds_source_src_10007.ds AS user__ds__day + , DATE_TRUNC('day', users_ds_source_src_10007.ds) AS user__ds__day , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS user__ds__week , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS user__ds__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS user__ds__quarter @@ -217,7 +217,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.ds) AS user__ds__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.ds) AS user__ds__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS user__ds__extract_doy - , users_ds_source_src_10007.created_at AS user__created_at__day + , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS user__created_at__day , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS user__created_at__week , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS user__created_at__month , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS user__created_at__quarter @@ -229,7 +229,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_doy - , users_ds_source_src_10007.ds_partitioned AS user__ds_partitioned__day + , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__day , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__week , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0_optimized.sql index 66ea172ae7..c15982d861 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_partitioned_join__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( -- Pass Only Elements: -- ['identity_verifications', 'ds_partitioned__day', 'user'] SELECT - ds_partitioned AS ds_partitioned__day + DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications FROM ***************************.fct_id_verifications id_verifications_src_10003 @@ -23,7 +23,7 @@ ON ( subq_10.user = users_ds_source_src_10007.user_id ) AND ( - subq_10.ds_partitioned__day = users_ds_source_src_10007.ds_partitioned + subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) ) GROUP BY users_ds_source_src_10007.home_state diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node__plan0.sql index 33fc914795..6c9249001c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node__plan0.sql @@ -37,7 +37,7 @@ FROM ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter @@ -77,7 +77,7 @@ INNER JOIN ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -90,7 +90,7 @@ INNER JOIN ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node__plan0_optimized.sql index d90abbd294..c35f358f2d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node__plan0_optimized.sql @@ -37,7 +37,7 @@ FROM ( account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy , account_type - , ds AS account__ds__day + , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week , DATE_TRUNC('month', ds) AS account__ds__month , DATE_TRUNC('quarter', ds) AS account__ds__quarter @@ -71,7 +71,7 @@ INNER JOIN ( -- Read Elements From Semantic Model 'accounts_source' -- Filter row on MIN(ds__day) SELECT - MIN(ds) AS ds__day__complete + MIN(DATE_TRUNC('day', ds)) AS ds__day__complete FROM ***************************.fct_accounts accounts_source_src_10000 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node_with_grouping__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node_with_grouping__plan0.sql index dc98b44d95..c98bf2362f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node_with_grouping__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node_with_grouping__plan0.sql @@ -37,7 +37,7 @@ FROM ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter @@ -78,7 +78,7 @@ INNER JOIN ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -91,7 +91,7 @@ INNER JOIN ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node_with_grouping__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node_with_grouping__plan0_optimized.sql index d723157d2a..bb14649634 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node_with_grouping__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node_with_grouping__plan0_optimized.sql @@ -37,7 +37,7 @@ FROM ( account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy , account_type - , ds AS account__ds__day + , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week , DATE_TRUNC('month', ds) AS account__ds__month , DATE_TRUNC('quarter', ds) AS account__ds__quarter @@ -72,7 +72,7 @@ INNER JOIN ( -- Filter row on MAX(ds__day) SELECT user_id AS user - , MAX(ds) AS ds__day__complete + , MAX(DATE_TRUNC('day', ds)) AS ds__day__complete FROM ***************************.fct_accounts accounts_source_src_10000 GROUP BY user_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node_with_queried_group_by__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node_with_queried_group_by__plan0.sql index 95274f2863..d42a779e8d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node_with_queried_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node_with_queried_group_by__plan0.sql @@ -37,7 +37,7 @@ FROM ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter @@ -78,7 +78,7 @@ INNER JOIN ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -91,7 +91,7 @@ INNER JOIN ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql index e0c877bdf1..89c29c7a7f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql @@ -37,7 +37,7 @@ FROM ( account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy , account_type - , ds AS account__ds__day + , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week , DATE_TRUNC('month', ds) AS account__ds__month , DATE_TRUNC('quarter', ds) AS account__ds__quarter @@ -72,7 +72,7 @@ INNER JOIN ( -- Filter row on MIN(ds__day) SELECT DATE_TRUNC('week', ds) AS ds__week - , MIN(ds) AS ds__day__complete + , MIN(DATE_TRUNC('day', ds)) AS ds__day__complete FROM ***************************.fct_accounts accounts_source_src_10000 GROUP BY DATE_TRUNC('week', ds) diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_simple_query_with_date_part__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_simple_query_with_date_part__plan0.sql index 3869c341c5..460694cf59 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_simple_query_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_simple_query_with_date_part__plan0.sql @@ -139,7 +139,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -151,7 +151,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -163,7 +163,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -176,7 +176,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -188,7 +188,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -200,7 +200,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_simple_query_with_multiple_date_parts__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_simple_query_with_multiple_date_parts__plan0.sql index b1321ec748..078ba0df0c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_simple_query_with_multiple_date_parts__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_simple_query_with_multiple_date_parts__plan0.sql @@ -164,7 +164,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -176,7 +176,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -188,7 +188,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -201,7 +201,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -213,7 +213,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -225,7 +225,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0.sql index 9c6e0a2676..7e054cfaa7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_single_join_node__plan0.sql @@ -26,7 +26,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -38,7 +38,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -75,7 +75,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -87,7 +87,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -120,7 +120,7 @@ LEFT OUTER JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -132,7 +132,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -147,7 +147,7 @@ LEFT OUTER JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -159,7 +159,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_source_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_source_node__plan0.sql index b9ae7f84a4..b2741d3532 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_source_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_source_node__plan0.sql @@ -15,7 +15,7 @@ SELECT , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -27,7 +27,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -39,7 +39,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -52,7 +52,7 @@ SELECT , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -64,7 +64,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -76,7 +76,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_source_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_source_node__plan0_optimized.sql index d1560d9ab0..ba6c6f95c0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_source_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/DuckDB/test_source_node__plan0_optimized.sql @@ -15,7 +15,7 @@ SELECT , booking_value AS approximate_continuous_booking_value_p99 , booking_value AS approximate_discrete_booking_value_p99 , is_instant - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -27,7 +27,7 @@ SELECT , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy - , ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS ds_partitioned__quarter @@ -39,7 +39,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS ds_partitioned__extract_doy - , paid_at AS paid_at__day + , DATE_TRUNC('day', paid_at) AS paid_at__day , DATE_TRUNC('week', paid_at) AS paid_at__week , DATE_TRUNC('month', paid_at) AS paid_at__month , DATE_TRUNC('quarter', paid_at) AS paid_at__quarter @@ -52,7 +52,7 @@ SELECT , EXTRACT(dow FROM paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS paid_at__extract_doy , is_instant AS booking__is_instant - , ds AS booking__ds__day + , DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('week', ds) AS booking__ds__week , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('quarter', ds) AS booking__ds__quarter @@ -64,7 +64,7 @@ SELECT , EXTRACT(day FROM ds) AS booking__ds__extract_day , EXTRACT(dow FROM ds) AS booking__ds__extract_dow , EXTRACT(doy FROM ds) AS booking__ds__extract_doy - , ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS booking__ds_partitioned__quarter @@ -76,7 +76,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS booking__ds_partitioned__extract_doy - , paid_at AS booking__paid_at__day + , DATE_TRUNC('day', paid_at) AS booking__paid_at__day , DATE_TRUNC('week', paid_at) AS booking__paid_at__week , DATE_TRUNC('month', paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_common_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_common_semantic_model__plan0.sql index b954d8927e..202450d6c4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_common_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_common_semantic_model__plan0.sql @@ -145,7 +145,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -157,7 +157,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -182,7 +182,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -374,7 +374,7 @@ FULL OUTER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -386,7 +386,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -398,7 +398,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -411,7 +411,7 @@ FULL OUTER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -423,7 +423,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -435,7 +435,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_common_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_common_semantic_model__plan0_optimized.sql index 6ac18252b5..552b4dc805 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_common_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_common_semantic_model__plan0_optimized.sql @@ -15,7 +15,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_12 @@ -30,11 +30,11 @@ FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) ) subq_19 ON subq_14.metric_time__day = subq_19.metric_time__day diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0.sql index b1bf877e84..2319f07e20 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node__plan0.sql @@ -39,7 +39,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -51,7 +51,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -76,7 +76,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -88,7 +88,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -100,7 +100,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -133,7 +133,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -145,7 +145,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -160,7 +160,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index 12e006e550..c6b9e0456b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -169,7 +169,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -218,7 +218,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -230,7 +230,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -339,7 +339,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -351,7 +351,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -366,7 +366,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -378,7 +378,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -514,7 +514,7 @@ FROM ( -- Read Elements From Semantic Model 'views_source' SELECT 1 AS views - , views_source_src_10009.ds AS ds__day + , DATE_TRUNC('day', views_source_src_10009.ds) AS ds__day , DATE_TRUNC('week', views_source_src_10009.ds) AS ds__week , DATE_TRUNC('month', views_source_src_10009.ds) AS ds__month , DATE_TRUNC('quarter', views_source_src_10009.ds) AS ds__quarter @@ -526,7 +526,7 @@ FROM ( , EXTRACT(day FROM views_source_src_10009.ds) AS ds__extract_day , EXTRACT(dow FROM views_source_src_10009.ds) AS ds__extract_dow , EXTRACT(doy FROM views_source_src_10009.ds) AS ds__extract_doy - , views_source_src_10009.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS ds_partitioned__quarter @@ -538,7 +538,7 @@ FROM ( , EXTRACT(day FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_doy - , views_source_src_10009.ds AS view__ds__day + , DATE_TRUNC('day', views_source_src_10009.ds) AS view__ds__day , DATE_TRUNC('week', views_source_src_10009.ds) AS view__ds__week , DATE_TRUNC('month', views_source_src_10009.ds) AS view__ds__month , DATE_TRUNC('quarter', views_source_src_10009.ds) AS view__ds__quarter @@ -550,7 +550,7 @@ FROM ( , EXTRACT(day FROM views_source_src_10009.ds) AS view__ds__extract_day , EXTRACT(dow FROM views_source_src_10009.ds) AS view__ds__extract_dow , EXTRACT(doy FROM views_source_src_10009.ds) AS view__ds__extract_doy - , views_source_src_10009.ds_partitioned AS view__ds_partitioned__day + , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__day , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__week , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__month , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__quarter @@ -657,7 +657,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -669,7 +669,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -684,7 +684,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -696,7 +696,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index ac2f0ab7de..4baa44160e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'ds__day', 'listing'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 @@ -49,7 +49,7 @@ INNER JOIN ( -- Pass Only Elements: -- ['views', 'ds__day', 'listing'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_10009 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql index bcb36633c9..a92832a02e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql @@ -42,7 +42,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -54,7 +54,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -66,7 +66,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -79,7 +79,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -91,7 +91,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -103,7 +103,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -136,7 +136,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -148,7 +148,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -163,7 +163,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -175,7 +175,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0.sql index cd879426f7..a90f9421e2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_compute_metrics_node_simple_expr__plan0.sql @@ -39,7 +39,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -51,7 +51,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -76,7 +76,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -88,7 +88,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -100,7 +100,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -133,7 +133,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -145,7 +145,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -160,7 +160,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_constrain_time_range_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_constrain_time_range_node__plan0.sql index 5b6dd99cc4..b274191665 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_constrain_time_range_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_constrain_time_range_node__plan0.sql @@ -33,7 +33,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -45,7 +45,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -57,7 +57,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -70,7 +70,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -82,7 +82,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -94,7 +94,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_constrain_time_range_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_constrain_time_range_node__plan0_optimized.sql index bfc4959615..207fa171fa 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_constrain_time_range_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_constrain_time_range_node__plan0_optimized.sql @@ -4,8 +4,8 @@ -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - ds AS ds__day - , ds AS metric_time__day + DATE_TRUNC('day', ds) AS ds__day + , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 -WHERE ds BETWEEN '2020-01-01' AND '2020-01-02' +WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0.sql index 6920a36691..3b92bc016a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric__plan0.sql @@ -59,7 +59,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -71,7 +71,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0.sql index 4080ab9420..b843616ed0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_grain_to_date__plan0.sql @@ -59,7 +59,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -71,7 +71,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0.sql index fcf74a5947..5ef2c1add0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_ds__plan0.sql @@ -56,7 +56,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -68,7 +68,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0.sql index 0143335613..5db12c7b97 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window__plan0.sql @@ -59,7 +59,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -71,7 +71,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 5cba3a3202..4a950ee81d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -101,7 +101,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -113,7 +113,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index c420ef636f..dfc97e9ec9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -9,6 +9,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time FROM ***************************.fct_revenue revenue_src_10006 -WHERE created_at BETWEEN '2000-01-01' AND '2020-01-01' +WHERE DATE_TRUNC('day', created_at) BETWEEN '2000-01-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql index 414159089b..375f61a3f6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0.sql @@ -101,7 +101,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -113,7 +113,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index e3387b51e4..c78471782b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -9,6 +9,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS trailing_2_months_revenue FROM ***************************.fct_revenue revenue_src_10006 -WHERE created_at BETWEEN '2019-12-01' AND '2020-01-01' +WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-12-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric__plan0.sql index 5b4011175d..bebcd049ee 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -379,7 +379,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -391,7 +391,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -403,7 +403,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -416,7 +416,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -428,7 +428,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -440,7 +440,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric__plan0_optimized.sql index 336e7623a6..ace6863100 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['referred_bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_13 @@ -39,7 +39,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_18 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql index d11a69936d..090069e6fb 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index 425f3c5f99..a952516e96 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_16 @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index b98d6d0f3d..73b332fea3 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index b458c826f3..e5a7e1789c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql index 5b316563f4..582ffce3e1 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0_optimized.sql index 7f04118d76..2f47d03f76 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_16 @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 846598c061..368623f50b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index 026e23e536..b664ba9129 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 2ca02e1c57..c982d54319 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -253,7 +253,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -265,7 +265,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -277,7 +277,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -290,7 +290,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -302,7 +302,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -314,7 +314,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -588,7 +588,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -600,7 +600,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -612,7 +612,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -625,7 +625,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -637,7 +637,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -649,7 +649,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index 393a00b806..35a3e9fade 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -22,7 +22,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_18 @@ -45,7 +45,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_26 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index f744592adf..20799cfafd 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -253,7 +253,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -265,7 +265,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -277,7 +277,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -290,7 +290,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -302,7 +302,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -314,7 +314,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -589,7 +589,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -601,7 +601,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -613,7 +613,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -626,7 +626,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -638,7 +638,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -650,7 +650,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 18d23b6fbf..e76f579ff2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -22,7 +22,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_18 @@ -46,7 +46,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_26 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0.sql index 9a9cd18ee2..9238f3555b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0.sql @@ -361,7 +361,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -373,7 +373,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -385,7 +385,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -398,7 +398,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -410,7 +410,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -422,7 +422,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0_optimized.sql index f43a5e4dc8..4bef094503 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -22,9 +22,9 @@ FROM ( ***************************.fct_bookings bookings_source_src_10001 ON ( - bookings_source_src_10001.ds <= subq_14.ds + DATE_TRUNC('day', bookings_source_src_10001.ds) <= subq_14.ds ) AND ( - bookings_source_src_10001.ds > subq_14.ds - MAKE_INTERVAL(days => 2) + DATE_TRUNC('day', bookings_source_src_10001.ds) > subq_14.ds - MAKE_INTERVAL(days => 2) ) ) subq_15 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0.sql index d49d04d52c..94a2d6e893 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -247,7 +247,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -259,7 +259,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -271,7 +271,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -284,7 +284,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -296,7 +296,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -308,7 +308,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index 52ee859e82..06c73ec54c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -16,7 +16,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_9 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_distinct_values__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_distinct_values__plan0.sql index 40f6785af3..86ba05d2c1 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_distinct_values__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_distinct_values__plan0.sql @@ -160,7 +160,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -184,7 +184,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -197,7 +197,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -209,7 +209,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -221,7 +221,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -330,7 +330,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -342,7 +342,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -357,7 +357,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -369,7 +369,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_node__plan0.sql index a43457fcbd..eaa8fb6dcf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_node__plan0.sql @@ -20,7 +20,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -32,7 +32,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -44,7 +44,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -57,7 +57,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -69,7 +69,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -81,7 +81,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_node__plan0.sql index a3ce23fb89..4f2da7c5cf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_node__plan0.sql @@ -26,7 +26,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -38,7 +38,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -75,7 +75,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -87,7 +87,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_node__plan0_optimized.sql index c850362ca3..98241721ca 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_node__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'ds__day'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_3 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0.sql index 70919d8caa..0022e1d7c4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -166,7 +166,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -178,7 +178,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -190,7 +190,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -203,7 +203,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -215,7 +215,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -227,7 +227,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -336,7 +336,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -348,7 +348,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -363,7 +363,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -375,7 +375,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0.sql index 6e4488a729..b8f50cd3cf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0.sql @@ -154,7 +154,7 @@ FROM ( , bookings_source_src_10015.booking_value AS average_booking_value , bookings_source_src_10015.booking_value AS booking_payments , bookings_source_src_10015.is_instant - , bookings_source_src_10015.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter @@ -166,7 +166,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter @@ -178,7 +178,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter @@ -191,7 +191,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy , bookings_source_src_10015.is_instant AS booking__is_instant - , bookings_source_src_10015.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter @@ -203,7 +203,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter @@ -215,7 +215,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0_optimized.sql index 86a2010b35..db1199fc2e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_scd_dimension__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10015 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index 9f23719b49..3a106515f6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -155,7 +155,7 @@ INNER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -167,7 +167,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -179,7 +179,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -192,7 +192,7 @@ INNER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -204,7 +204,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -216,7 +216,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index 6a4ced8cd8..d0748a2ddb 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -23,12 +23,12 @@ INNER JOIN ( -- ['booking_value', 'metric_time__day', 'listing'] -- Aggregate Measures SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) , listing_id ) subq_10 ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0.sql index cb25d5128e..32bdb6d1cc 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -155,7 +155,7 @@ INNER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -167,7 +167,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -179,7 +179,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -192,7 +192,7 @@ INNER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -204,7 +204,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -216,7 +216,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index e117c67c83..1efe236f6f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -23,12 +23,12 @@ INNER JOIN ( -- ['booking_value', 'metric_time__day', 'listing'] -- Aggregate Measures SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) , listing_id ) subq_10 ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0.sql index 2093e49b0b..457449a984 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0.sql @@ -155,7 +155,7 @@ INNER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -167,7 +167,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -179,7 +179,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -192,7 +192,7 @@ INNER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -204,7 +204,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -216,7 +216,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index 4afadfc929..26398b9d40 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -23,12 +23,12 @@ INNER JOIN ( -- ['booking_value', 'metric_time__day', 'listing'] -- Aggregate Measures SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) , listing_id ) subq_10 ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_limit_rows__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_limit_rows__plan0.sql index eb506ddf59..7fd977201f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_limit_rows__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_limit_rows__plan0.sql @@ -144,7 +144,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -156,7 +156,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_limit_rows__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_limit_rows__plan0_optimized.sql index 6db56759fc..e52871ff7c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_limit_rows__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_limit_rows__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'ds__day'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_7 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0.sql index d5688f0e2d..2ff36d921e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_local_dimension_using_local_entity__plan0.sql @@ -94,7 +94,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -106,7 +106,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -121,7 +121,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -133,7 +133,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_aggregation_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_aggregation_node__plan0.sql index dbfcb34b94..7ebbd78174 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_aggregation_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_aggregation_node__plan0.sql @@ -30,7 +30,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -42,7 +42,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -54,7 +54,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -67,7 +67,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -79,7 +79,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -91,7 +91,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql index e5349b0d17..961480acb5 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0.sql @@ -178,7 +178,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -190,7 +190,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -202,7 +202,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -215,7 +215,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -227,7 +227,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -239,7 +239,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -348,7 +348,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -360,7 +360,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -375,7 +375,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -387,7 +387,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -589,7 +589,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -601,7 +601,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -613,7 +613,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -626,7 +626,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -638,7 +638,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -650,7 +650,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -759,7 +759,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -771,7 +771,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -786,7 +786,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -798,7 +798,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -983,7 +983,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -995,7 +995,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -1007,7 +1007,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -1020,7 +1020,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -1032,7 +1032,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -1044,7 +1044,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0_optimized.sql index eb22b75d5e..bf23abb3af 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint__plan0_optimized.sql @@ -23,7 +23,7 @@ FROM ( -- Pass Only Elements: -- ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - bookings_source_src_10001.ds AS metric_time__day + DATE_TRUNC('day', bookings_source_src_10001.ds) AS metric_time__day , listings_latest_src_10004.is_lux AS listing__is_lux_latest , bookings_source_src_10001.booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_10001 @@ -59,7 +59,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 @@ -91,11 +91,11 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) ) subq_58 ON ( diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql index 61d8df3842..959bc32391 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0.sql @@ -163,7 +163,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -175,7 +175,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -200,7 +200,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -212,7 +212,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -224,7 +224,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -395,7 +395,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -407,7 +407,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -419,7 +419,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -432,7 +432,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -444,7 +444,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -456,7 +456,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0_optimized.sql index 3972067afa..c466ba6856 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -18,7 +18,7 @@ FROM ( -- Pass Only Elements: -- ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_10001 @@ -35,11 +35,11 @@ INNER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) ) subq_24 ON ( diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0.sql index bd41d48bd9..58e129bcbe 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -157,7 +157,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -218,7 +218,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index c012c97a59..18094198a4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -17,7 +17,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index edfbb1483f..83446acbbf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -145,7 +145,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -157,7 +157,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -182,7 +182,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -324,7 +324,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -336,7 +336,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -351,7 +351,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -363,7 +363,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql index 79946c1bc1..16fde28343 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0.sql @@ -144,7 +144,7 @@ FROM ( , bookings_source_src_10015.booking_value AS average_booking_value , bookings_source_src_10015.booking_value AS booking_payments , bookings_source_src_10015.is_instant - , bookings_source_src_10015.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter @@ -156,7 +156,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy , bookings_source_src_10015.is_instant AS booking__is_instant - , bookings_source_src_10015.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter @@ -432,7 +432,7 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - users_latest_src_10021.ds AS ds__day + DATE_TRUNC('day', users_latest_src_10021.ds) AS ds__day , DATE_TRUNC('week', users_latest_src_10021.ds) AS ds__week , DATE_TRUNC('month', users_latest_src_10021.ds) AS ds__month , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS ds__quarter @@ -445,7 +445,7 @@ FROM ( , EXTRACT(dow FROM users_latest_src_10021.ds) AS ds__extract_dow , EXTRACT(doy FROM users_latest_src_10021.ds) AS ds__extract_doy , users_latest_src_10021.home_state_latest - , users_latest_src_10021.ds AS user__ds__day + , DATE_TRUNC('day', users_latest_src_10021.ds) AS user__ds__day , DATE_TRUNC('week', users_latest_src_10021.ds) AS user__ds__week , DATE_TRUNC('month', users_latest_src_10021.ds) AS user__ds__month , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS user__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql index feb5ed0fdc..aa2ad14d34 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -13,7 +13,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10015 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql index 1cfb7780a7..a3e98c1218 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0.sql @@ -144,7 +144,7 @@ FROM ( , bookings_source_src_10015.booking_value AS average_booking_value , bookings_source_src_10015.booking_value AS booking_payments , bookings_source_src_10015.is_instant - , bookings_source_src_10015.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter @@ -156,7 +156,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy , bookings_source_src_10015.is_instant AS booking__is_instant - , bookings_source_src_10015.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql index f1b419a284..add7e259ab 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -13,7 +13,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10015 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0.sql index 7e38380b20..18a7c52fef 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multi_join_node__plan0.sql @@ -28,7 +28,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -40,7 +40,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -52,7 +52,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -65,7 +65,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -77,7 +77,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -89,7 +89,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -122,7 +122,7 @@ LEFT OUTER JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -134,7 +134,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -149,7 +149,7 @@ LEFT OUTER JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -161,7 +161,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -196,7 +196,7 @@ LEFT OUTER JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -208,7 +208,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -223,7 +223,7 @@ LEFT OUTER JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -235,7 +235,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql index c742d95f11..5b4b817799 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multihop_node__plan0.sql @@ -99,7 +99,7 @@ FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT account_month_txns_src_10010.txn_count - , account_month_txns_src_10010.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__quarter @@ -111,7 +111,7 @@ FROM ( , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_doy - , account_month_txns_src_10010.ds AS ds__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS ds__day , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS ds__week , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS ds__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS ds__quarter @@ -124,7 +124,7 @@ FROM ( , EXTRACT(dow FROM account_month_txns_src_10010.ds) AS ds__extract_dow , EXTRACT(doy FROM account_month_txns_src_10010.ds) AS ds__extract_doy , account_month_txns_src_10010.account_month - , account_month_txns_src_10010.ds_partitioned AS account_id__ds_partitioned__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__day , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__week , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__quarter @@ -136,7 +136,7 @@ FROM ( , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_day , EXTRACT(dow FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_dow , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , account_month_txns_src_10010.ds AS account_id__ds__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS account_id__ds__day , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS account_id__ds__week , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS account_id__ds__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS account_id__ds__quarter @@ -226,7 +226,7 @@ FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT bridge_table_src_10011.extra_dim - , bridge_table_src_10011.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__quarter @@ -239,7 +239,7 @@ FROM ( , EXTRACT(dow FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_doy , bridge_table_src_10011.extra_dim AS account_id__extra_dim - , bridge_table_src_10011.ds_partitioned AS account_id__ds_partitioned__day + , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__day , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__week , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__month , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__quarter @@ -252,7 +252,7 @@ FROM ( , EXTRACT(dow FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_dow , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_doy , bridge_table_src_10011.extra_dim AS bridge_account__extra_dim - , bridge_table_src_10011.ds_partitioned AS bridge_account__ds_partitioned__day + , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__day , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__week , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__month , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__quarter @@ -337,7 +337,7 @@ FROM ( SELECT customer_table_src_10013.customer_name , customer_table_src_10013.customer_atomic_weight - , customer_table_src_10013.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS ds_partitioned__quarter @@ -351,7 +351,7 @@ FROM ( , EXTRACT(doy FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_doy , customer_table_src_10013.customer_name AS customer_id__customer_name , customer_table_src_10013.customer_atomic_weight AS customer_id__customer_atomic_weight - , customer_table_src_10013.ds_partitioned AS customer_id__ds_partitioned__day + , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__day , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__week , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__month , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql index ba4bf14fba..8a42052413 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multihop_node__plan0_optimized.sql @@ -12,7 +12,7 @@ LEFT OUTER JOIN ( -- Pass Only Elements: -- ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - bridge_table_src_10011.ds_partitioned AS ds_partitioned__day + DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day , bridge_table_src_10011.account_id AS account_id , customer_table_src_10013.customer_name AS customer_id__customer_name FROM ***************************.bridge_table bridge_table_src_10011 @@ -22,14 +22,14 @@ LEFT OUTER JOIN ( ( bridge_table_src_10011.customer_id = customer_table_src_10013.customer_id ) AND ( - bridge_table_src_10011.ds_partitioned = customer_table_src_10013.ds_partitioned + DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) = DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) ) ) subq_18 ON ( account_month_txns_src_10010.account_id = subq_18.account_id ) AND ( - account_month_txns_src_10010.ds_partitioned = subq_18.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) = subq_18.ds_partitioned__day ) GROUP BY subq_18.customer_id__customer_name diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0.sql index 54b108dd33..df6a1ebfc8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0.sql @@ -249,7 +249,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -261,7 +261,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -273,7 +273,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -286,7 +286,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -298,7 +298,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -310,7 +310,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -505,7 +505,7 @@ CROSS JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -517,7 +517,7 @@ CROSS JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -532,7 +532,7 @@ CROSS JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -544,7 +544,7 @@ CROSS JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 74dcbb71f8..56554460d5 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -13,7 +13,7 @@ FROM ( SELECT SUM(1) AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 - WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' + WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-01' ) subq_17 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' @@ -26,5 +26,5 @@ CROSS JOIN ( SELECT SUM(1) AS listings FROM ***************************.dim_listings_latest listings_latest_src_10004 - WHERE created_at BETWEEN '2020-01-01' AND '2020-01-01' + WHERE DATE_TRUNC('day', created_at) BETWEEN '2020-01-01' AND '2020-01-01' ) subq_23 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0.sql index a716977aaf..bd98232377 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0.sql @@ -162,7 +162,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -186,7 +186,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -223,7 +223,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -391,7 +391,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -403,7 +403,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -415,7 +415,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -428,7 +428,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -440,7 +440,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -452,7 +452,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -632,7 +632,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -644,7 +644,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -656,7 +656,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -669,7 +669,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -681,7 +681,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -693,7 +693,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -871,7 +871,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -883,7 +883,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -895,7 +895,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -908,7 +908,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -920,7 +920,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -932,7 +932,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0_optimized.sql index e45cf8bb70..519c4b6ea5 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_nested_derived_metric__plan0_optimized.sql @@ -32,7 +32,7 @@ FROM ( -- Pass Only Elements: -- ['referred_bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_25 @@ -51,7 +51,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_30 @@ -82,7 +82,7 @@ FROM ( -- Pass Only Elements: -- ['instant_bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_37 @@ -111,7 +111,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_42 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0.sql index 17b1104b28..1a8667ef7f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0_optimized.sql index 0ddba9f210..6879bfae56 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_offset_window_with_date_part__plan0_optimized.sql @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_order_by_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_order_by_node__plan0.sql index d6632b499f..5aaceec9da 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_order_by_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_order_by_node__plan0.sql @@ -40,7 +40,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -52,7 +52,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -64,7 +64,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -77,7 +77,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -89,7 +89,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -101,7 +101,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_order_by_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_order_by_node__plan0_optimized.sql index efe34b261f..b0e38b1d22 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_order_by_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_order_by_node__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'is_instant', 'ds__day'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql index 44cff4ab94..778bddf502 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0.sql @@ -101,7 +101,7 @@ FROM ( -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , id_verifications_src_10003.ds AS ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter @@ -113,7 +113,7 @@ FROM ( , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter @@ -126,7 +126,7 @@ FROM ( , EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy , id_verifications_src_10003.verification_type - , id_verifications_src_10003.ds AS verification__ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter @@ -138,7 +138,7 @@ FROM ( , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS verification__ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT - users_ds_source_src_10007.ds AS ds__day + DATE_TRUNC('day', users_ds_source_src_10007.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS ds__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS ds__quarter @@ -180,7 +180,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.ds) AS ds__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.ds) AS ds__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS ds__extract_doy - , users_ds_source_src_10007.created_at AS created_at__day + , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS created_at__day , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS created_at__week , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS created_at__month , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS created_at__quarter @@ -192,7 +192,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS created_at__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.created_at) AS created_at__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS created_at__extract_doy - , users_ds_source_src_10007.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(dow FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_doy , users_ds_source_src_10007.home_state - , users_ds_source_src_10007.ds AS user__ds__day + , DATE_TRUNC('day', users_ds_source_src_10007.ds) AS user__ds__day , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS user__ds__week , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS user__ds__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS user__ds__quarter @@ -217,7 +217,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.ds) AS user__ds__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.ds) AS user__ds__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS user__ds__extract_doy - , users_ds_source_src_10007.created_at AS user__created_at__day + , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS user__created_at__day , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS user__created_at__week , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS user__created_at__month , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS user__created_at__quarter @@ -229,7 +229,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_doy - , users_ds_source_src_10007.ds_partitioned AS user__ds_partitioned__day + , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__day , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__week , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0_optimized.sql index 66ea172ae7..c15982d861 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_partitioned_join__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( -- Pass Only Elements: -- ['identity_verifications', 'ds_partitioned__day', 'user'] SELECT - ds_partitioned AS ds_partitioned__day + DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications FROM ***************************.fct_id_verifications id_verifications_src_10003 @@ -23,7 +23,7 @@ ON ( subq_10.user = users_ds_source_src_10007.user_id ) AND ( - subq_10.ds_partitioned__day = users_ds_source_src_10007.ds_partitioned + subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) ) GROUP BY users_ds_source_src_10007.home_state diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node__plan0.sql index 33fc914795..6c9249001c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node__plan0.sql @@ -37,7 +37,7 @@ FROM ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter @@ -77,7 +77,7 @@ INNER JOIN ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -90,7 +90,7 @@ INNER JOIN ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node__plan0_optimized.sql index d90abbd294..c35f358f2d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node__plan0_optimized.sql @@ -37,7 +37,7 @@ FROM ( account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy , account_type - , ds AS account__ds__day + , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week , DATE_TRUNC('month', ds) AS account__ds__month , DATE_TRUNC('quarter', ds) AS account__ds__quarter @@ -71,7 +71,7 @@ INNER JOIN ( -- Read Elements From Semantic Model 'accounts_source' -- Filter row on MIN(ds__day) SELECT - MIN(ds) AS ds__day__complete + MIN(DATE_TRUNC('day', ds)) AS ds__day__complete FROM ***************************.fct_accounts accounts_source_src_10000 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_grouping__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_grouping__plan0.sql index dc98b44d95..c98bf2362f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_grouping__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_grouping__plan0.sql @@ -37,7 +37,7 @@ FROM ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter @@ -78,7 +78,7 @@ INNER JOIN ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -91,7 +91,7 @@ INNER JOIN ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_grouping__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_grouping__plan0_optimized.sql index d723157d2a..bb14649634 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_grouping__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_grouping__plan0_optimized.sql @@ -37,7 +37,7 @@ FROM ( account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy , account_type - , ds AS account__ds__day + , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week , DATE_TRUNC('month', ds) AS account__ds__month , DATE_TRUNC('quarter', ds) AS account__ds__quarter @@ -72,7 +72,7 @@ INNER JOIN ( -- Filter row on MAX(ds__day) SELECT user_id AS user - , MAX(ds) AS ds__day__complete + , MAX(DATE_TRUNC('day', ds)) AS ds__day__complete FROM ***************************.fct_accounts accounts_source_src_10000 GROUP BY user_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_queried_group_by__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_queried_group_by__plan0.sql index 95274f2863..d42a779e8d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_queried_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_queried_group_by__plan0.sql @@ -37,7 +37,7 @@ FROM ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter @@ -78,7 +78,7 @@ INNER JOIN ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -91,7 +91,7 @@ INNER JOIN ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql index e0c877bdf1..89c29c7a7f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql @@ -37,7 +37,7 @@ FROM ( account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy , account_type - , ds AS account__ds__day + , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week , DATE_TRUNC('month', ds) AS account__ds__month , DATE_TRUNC('quarter', ds) AS account__ds__quarter @@ -72,7 +72,7 @@ INNER JOIN ( -- Filter row on MIN(ds__day) SELECT DATE_TRUNC('week', ds) AS ds__week - , MIN(ds) AS ds__day__complete + , MIN(DATE_TRUNC('day', ds)) AS ds__day__complete FROM ***************************.fct_accounts accounts_source_src_10000 GROUP BY DATE_TRUNC('week', ds) diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_simple_query_with_date_part__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_simple_query_with_date_part__plan0.sql index 3869c341c5..460694cf59 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_simple_query_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_simple_query_with_date_part__plan0.sql @@ -139,7 +139,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -151,7 +151,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -163,7 +163,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -176,7 +176,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -188,7 +188,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -200,7 +200,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_simple_query_with_multiple_date_parts__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_simple_query_with_multiple_date_parts__plan0.sql index b1321ec748..078ba0df0c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_simple_query_with_multiple_date_parts__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_simple_query_with_multiple_date_parts__plan0.sql @@ -164,7 +164,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -176,7 +176,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -188,7 +188,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -201,7 +201,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -213,7 +213,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -225,7 +225,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0.sql index 9c6e0a2676..7e054cfaa7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_single_join_node__plan0.sql @@ -26,7 +26,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -38,7 +38,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -75,7 +75,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -87,7 +87,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -120,7 +120,7 @@ LEFT OUTER JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -132,7 +132,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -147,7 +147,7 @@ LEFT OUTER JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -159,7 +159,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_source_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_source_node__plan0.sql index b9ae7f84a4..b2741d3532 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_source_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_source_node__plan0.sql @@ -15,7 +15,7 @@ SELECT , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -27,7 +27,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -39,7 +39,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -52,7 +52,7 @@ SELECT , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -64,7 +64,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -76,7 +76,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_source_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_source_node__plan0_optimized.sql index d1560d9ab0..ba6c6f95c0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_source_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Postgres/test_source_node__plan0_optimized.sql @@ -15,7 +15,7 @@ SELECT , booking_value AS approximate_continuous_booking_value_p99 , booking_value AS approximate_discrete_booking_value_p99 , is_instant - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -27,7 +27,7 @@ SELECT , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy - , ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS ds_partitioned__quarter @@ -39,7 +39,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS ds_partitioned__extract_doy - , paid_at AS paid_at__day + , DATE_TRUNC('day', paid_at) AS paid_at__day , DATE_TRUNC('week', paid_at) AS paid_at__week , DATE_TRUNC('month', paid_at) AS paid_at__month , DATE_TRUNC('quarter', paid_at) AS paid_at__quarter @@ -52,7 +52,7 @@ SELECT , EXTRACT(dow FROM paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS paid_at__extract_doy , is_instant AS booking__is_instant - , ds AS booking__ds__day + , DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('week', ds) AS booking__ds__week , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('quarter', ds) AS booking__ds__quarter @@ -64,7 +64,7 @@ SELECT , EXTRACT(day FROM ds) AS booking__ds__extract_day , EXTRACT(dow FROM ds) AS booking__ds__extract_dow , EXTRACT(doy FROM ds) AS booking__ds__extract_doy - , ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS booking__ds_partitioned__quarter @@ -76,7 +76,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS booking__ds_partitioned__extract_doy - , paid_at AS booking__paid_at__day + , DATE_TRUNC('day', paid_at) AS booking__paid_at__day , DATE_TRUNC('week', paid_at) AS booking__paid_at__week , DATE_TRUNC('month', paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_common_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_common_semantic_model__plan0.sql index b954d8927e..202450d6c4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_common_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_common_semantic_model__plan0.sql @@ -145,7 +145,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -157,7 +157,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -182,7 +182,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -374,7 +374,7 @@ FULL OUTER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -386,7 +386,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -398,7 +398,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -411,7 +411,7 @@ FULL OUTER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -423,7 +423,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -435,7 +435,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_common_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_common_semantic_model__plan0_optimized.sql index 6ac18252b5..552b4dc805 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_common_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_common_semantic_model__plan0_optimized.sql @@ -15,7 +15,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_12 @@ -30,11 +30,11 @@ FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) ) subq_19 ON subq_14.metric_time__day = subq_19.metric_time__day diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0.sql index b1bf877e84..2319f07e20 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node__plan0.sql @@ -39,7 +39,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -51,7 +51,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -76,7 +76,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -88,7 +88,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -100,7 +100,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -133,7 +133,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -145,7 +145,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -160,7 +160,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index 12e006e550..c6b9e0456b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -169,7 +169,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -218,7 +218,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -230,7 +230,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -339,7 +339,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -351,7 +351,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -366,7 +366,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -378,7 +378,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -514,7 +514,7 @@ FROM ( -- Read Elements From Semantic Model 'views_source' SELECT 1 AS views - , views_source_src_10009.ds AS ds__day + , DATE_TRUNC('day', views_source_src_10009.ds) AS ds__day , DATE_TRUNC('week', views_source_src_10009.ds) AS ds__week , DATE_TRUNC('month', views_source_src_10009.ds) AS ds__month , DATE_TRUNC('quarter', views_source_src_10009.ds) AS ds__quarter @@ -526,7 +526,7 @@ FROM ( , EXTRACT(day FROM views_source_src_10009.ds) AS ds__extract_day , EXTRACT(dow FROM views_source_src_10009.ds) AS ds__extract_dow , EXTRACT(doy FROM views_source_src_10009.ds) AS ds__extract_doy - , views_source_src_10009.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS ds_partitioned__quarter @@ -538,7 +538,7 @@ FROM ( , EXTRACT(day FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_doy - , views_source_src_10009.ds AS view__ds__day + , DATE_TRUNC('day', views_source_src_10009.ds) AS view__ds__day , DATE_TRUNC('week', views_source_src_10009.ds) AS view__ds__week , DATE_TRUNC('month', views_source_src_10009.ds) AS view__ds__month , DATE_TRUNC('quarter', views_source_src_10009.ds) AS view__ds__quarter @@ -550,7 +550,7 @@ FROM ( , EXTRACT(day FROM views_source_src_10009.ds) AS view__ds__extract_day , EXTRACT(dow FROM views_source_src_10009.ds) AS view__ds__extract_dow , EXTRACT(doy FROM views_source_src_10009.ds) AS view__ds__extract_doy - , views_source_src_10009.ds_partitioned AS view__ds_partitioned__day + , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__day , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__week , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__month , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__quarter @@ -657,7 +657,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -669,7 +669,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -684,7 +684,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -696,7 +696,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index ac2f0ab7de..4baa44160e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'ds__day', 'listing'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 @@ -49,7 +49,7 @@ INNER JOIN ( -- Pass Only Elements: -- ['views', 'ds__day', 'listing'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_10009 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql index bcb36633c9..a92832a02e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql @@ -42,7 +42,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -54,7 +54,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -66,7 +66,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -79,7 +79,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -91,7 +91,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -103,7 +103,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -136,7 +136,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -148,7 +148,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -163,7 +163,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -175,7 +175,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0.sql index cd879426f7..a90f9421e2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_compute_metrics_node_simple_expr__plan0.sql @@ -39,7 +39,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -51,7 +51,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -76,7 +76,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -88,7 +88,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -100,7 +100,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -133,7 +133,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -145,7 +145,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -160,7 +160,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_constrain_time_range_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_constrain_time_range_node__plan0.sql index 5b6dd99cc4..b274191665 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_constrain_time_range_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_constrain_time_range_node__plan0.sql @@ -33,7 +33,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -45,7 +45,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -57,7 +57,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -70,7 +70,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -82,7 +82,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -94,7 +94,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_constrain_time_range_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_constrain_time_range_node__plan0_optimized.sql index bfc4959615..207fa171fa 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_constrain_time_range_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_constrain_time_range_node__plan0_optimized.sql @@ -4,8 +4,8 @@ -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - ds AS ds__day - , ds AS metric_time__day + DATE_TRUNC('day', ds) AS ds__day + , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 -WHERE ds BETWEEN '2020-01-01' AND '2020-01-02' +WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0.sql index 6920a36691..3b92bc016a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric__plan0.sql @@ -59,7 +59,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -71,7 +71,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0.sql index 4080ab9420..b843616ed0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_grain_to_date__plan0.sql @@ -59,7 +59,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -71,7 +71,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0.sql index fcf74a5947..5ef2c1add0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_ds__plan0.sql @@ -56,7 +56,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -68,7 +68,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0.sql index 0143335613..5db12c7b97 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window__plan0.sql @@ -59,7 +59,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -71,7 +71,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 5cba3a3202..4a950ee81d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -101,7 +101,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -113,7 +113,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index c420ef636f..dfc97e9ec9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -9,6 +9,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time FROM ***************************.fct_revenue revenue_src_10006 -WHERE created_at BETWEEN '2000-01-01' AND '2020-01-01' +WHERE DATE_TRUNC('day', created_at) BETWEEN '2000-01-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql index 414159089b..375f61a3f6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0.sql @@ -101,7 +101,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -113,7 +113,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index e3387b51e4..c78471782b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -9,6 +9,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS trailing_2_months_revenue FROM ***************************.fct_revenue revenue_src_10006 -WHERE created_at BETWEEN '2019-12-01' AND '2020-01-01' +WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-12-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric__plan0.sql index 5b4011175d..bebcd049ee 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -379,7 +379,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -391,7 +391,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -403,7 +403,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -416,7 +416,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -428,7 +428,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -440,7 +440,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric__plan0_optimized.sql index 336e7623a6..ace6863100 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['referred_bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_13 @@ -39,7 +39,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_18 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql index d11a69936d..090069e6fb 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index 425f3c5f99..a952516e96 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_16 @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index b98d6d0f3d..73b332fea3 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index b458c826f3..e5a7e1789c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql index 9139bc862d..8461e53fc4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0_optimized.sql index 80c5452e0d..d79d809654 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_16 @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 0022a4f526..d840b06e43 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index c5d0b45b69..bbdb2547b7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 10bb6c0450..a6df144424 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -253,7 +253,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -265,7 +265,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -277,7 +277,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -290,7 +290,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -302,7 +302,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -314,7 +314,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -588,7 +588,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -600,7 +600,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -612,7 +612,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -625,7 +625,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -637,7 +637,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -649,7 +649,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index fb585a52b9..3f57ba0cbf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -22,7 +22,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_18 @@ -45,7 +45,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_26 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index 1aaa96b40a..4b45c0edc7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -253,7 +253,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -265,7 +265,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -277,7 +277,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -290,7 +290,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -302,7 +302,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -314,7 +314,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -589,7 +589,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -601,7 +601,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -613,7 +613,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -626,7 +626,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -638,7 +638,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -650,7 +650,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 966f139fe1..40dd779220 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -22,7 +22,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_18 @@ -46,7 +46,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_26 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0.sql index 3107752f3d..9c5c91984c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0.sql @@ -361,7 +361,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -373,7 +373,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -385,7 +385,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -398,7 +398,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -410,7 +410,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -422,7 +422,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0_optimized.sql index b99a126d9b..9609d10b3f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -22,9 +22,9 @@ FROM ( ***************************.fct_bookings bookings_source_src_10001 ON ( - bookings_source_src_10001.ds <= subq_14.ds + DATE_TRUNC('day', bookings_source_src_10001.ds) <= subq_14.ds ) AND ( - bookings_source_src_10001.ds > DATEADD(day, -2, subq_14.ds) + DATE_TRUNC('day', bookings_source_src_10001.ds) > DATEADD(day, -2, subq_14.ds) ) ) subq_15 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0.sql index 666e2d3376..0ea424f256 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -247,7 +247,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -259,7 +259,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -271,7 +271,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -284,7 +284,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -296,7 +296,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -308,7 +308,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index 43a78551de..5ede4be6d6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -16,7 +16,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_9 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_distinct_values__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_distinct_values__plan0.sql index 40f6785af3..86ba05d2c1 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_distinct_values__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_distinct_values__plan0.sql @@ -160,7 +160,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -184,7 +184,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -197,7 +197,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -209,7 +209,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -221,7 +221,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -330,7 +330,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -342,7 +342,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -357,7 +357,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -369,7 +369,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_node__plan0.sql index a43457fcbd..eaa8fb6dcf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_node__plan0.sql @@ -20,7 +20,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -32,7 +32,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -44,7 +44,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -57,7 +57,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -69,7 +69,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -81,7 +81,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_node__plan0.sql index a3ce23fb89..4f2da7c5cf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_node__plan0.sql @@ -26,7 +26,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -38,7 +38,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -75,7 +75,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -87,7 +87,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_node__plan0_optimized.sql index c850362ca3..98241721ca 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_node__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'ds__day'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_3 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0.sql index 70919d8caa..0022e1d7c4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -166,7 +166,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -178,7 +178,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -190,7 +190,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -203,7 +203,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -215,7 +215,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -227,7 +227,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -336,7 +336,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -348,7 +348,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -363,7 +363,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -375,7 +375,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0.sql index 6e4488a729..b8f50cd3cf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0.sql @@ -154,7 +154,7 @@ FROM ( , bookings_source_src_10015.booking_value AS average_booking_value , bookings_source_src_10015.booking_value AS booking_payments , bookings_source_src_10015.is_instant - , bookings_source_src_10015.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter @@ -166,7 +166,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter @@ -178,7 +178,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter @@ -191,7 +191,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy , bookings_source_src_10015.is_instant AS booking__is_instant - , bookings_source_src_10015.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter @@ -203,7 +203,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter @@ -215,7 +215,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0_optimized.sql index 86a2010b35..db1199fc2e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_scd_dimension__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10015 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index 9f23719b49..3a106515f6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -155,7 +155,7 @@ INNER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -167,7 +167,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -179,7 +179,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -192,7 +192,7 @@ INNER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -204,7 +204,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -216,7 +216,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index 6a4ced8cd8..d0748a2ddb 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -23,12 +23,12 @@ INNER JOIN ( -- ['booking_value', 'metric_time__day', 'listing'] -- Aggregate Measures SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) , listing_id ) subq_10 ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0.sql index 1c6b0467ff..29d0ec4e19 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -155,7 +155,7 @@ INNER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -167,7 +167,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -179,7 +179,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -192,7 +192,7 @@ INNER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -204,7 +204,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -216,7 +216,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index f5c740c47c..cc0dcc2828 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -23,12 +23,12 @@ INNER JOIN ( -- ['booking_value', 'metric_time__day', 'listing'] -- Aggregate Measures SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) , listing_id ) subq_10 ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0.sql index 2093e49b0b..457449a984 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0.sql @@ -155,7 +155,7 @@ INNER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -167,7 +167,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -179,7 +179,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -192,7 +192,7 @@ INNER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -204,7 +204,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -216,7 +216,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index 4afadfc929..26398b9d40 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -23,12 +23,12 @@ INNER JOIN ( -- ['booking_value', 'metric_time__day', 'listing'] -- Aggregate Measures SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) , listing_id ) subq_10 ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_limit_rows__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_limit_rows__plan0.sql index eb506ddf59..7fd977201f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_limit_rows__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_limit_rows__plan0.sql @@ -144,7 +144,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -156,7 +156,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_limit_rows__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_limit_rows__plan0_optimized.sql index 6db56759fc..e52871ff7c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_limit_rows__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_limit_rows__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'ds__day'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_7 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0.sql index d5688f0e2d..2ff36d921e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_local_dimension_using_local_entity__plan0.sql @@ -94,7 +94,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -106,7 +106,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -121,7 +121,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -133,7 +133,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_aggregation_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_aggregation_node__plan0.sql index dbfcb34b94..7ebbd78174 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_aggregation_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_aggregation_node__plan0.sql @@ -30,7 +30,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -42,7 +42,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -54,7 +54,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -67,7 +67,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -79,7 +79,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -91,7 +91,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql index e5349b0d17..961480acb5 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0.sql @@ -178,7 +178,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -190,7 +190,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -202,7 +202,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -215,7 +215,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -227,7 +227,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -239,7 +239,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -348,7 +348,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -360,7 +360,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -375,7 +375,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -387,7 +387,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -589,7 +589,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -601,7 +601,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -613,7 +613,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -626,7 +626,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -638,7 +638,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -650,7 +650,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -759,7 +759,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -771,7 +771,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -786,7 +786,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -798,7 +798,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -983,7 +983,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -995,7 +995,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -1007,7 +1007,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -1020,7 +1020,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -1032,7 +1032,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -1044,7 +1044,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0_optimized.sql index eb22b75d5e..bf23abb3af 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint__plan0_optimized.sql @@ -23,7 +23,7 @@ FROM ( -- Pass Only Elements: -- ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - bookings_source_src_10001.ds AS metric_time__day + DATE_TRUNC('day', bookings_source_src_10001.ds) AS metric_time__day , listings_latest_src_10004.is_lux AS listing__is_lux_latest , bookings_source_src_10001.booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_10001 @@ -59,7 +59,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 @@ -91,11 +91,11 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) ) subq_58 ON ( diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql index 61d8df3842..959bc32391 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0.sql @@ -163,7 +163,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -175,7 +175,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -200,7 +200,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -212,7 +212,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -224,7 +224,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -395,7 +395,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -407,7 +407,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -419,7 +419,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -432,7 +432,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -444,7 +444,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -456,7 +456,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0_optimized.sql index 3972067afa..c466ba6856 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -18,7 +18,7 @@ FROM ( -- Pass Only Elements: -- ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_10001 @@ -35,11 +35,11 @@ INNER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) ) subq_24 ON ( diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0.sql index bd41d48bd9..58e129bcbe 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -157,7 +157,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -218,7 +218,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index c012c97a59..18094198a4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -17,7 +17,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index edfbb1483f..83446acbbf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -145,7 +145,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -157,7 +157,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -182,7 +182,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -324,7 +324,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -336,7 +336,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -351,7 +351,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -363,7 +363,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql index 79946c1bc1..16fde28343 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0.sql @@ -144,7 +144,7 @@ FROM ( , bookings_source_src_10015.booking_value AS average_booking_value , bookings_source_src_10015.booking_value AS booking_payments , bookings_source_src_10015.is_instant - , bookings_source_src_10015.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter @@ -156,7 +156,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy , bookings_source_src_10015.is_instant AS booking__is_instant - , bookings_source_src_10015.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter @@ -432,7 +432,7 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - users_latest_src_10021.ds AS ds__day + DATE_TRUNC('day', users_latest_src_10021.ds) AS ds__day , DATE_TRUNC('week', users_latest_src_10021.ds) AS ds__week , DATE_TRUNC('month', users_latest_src_10021.ds) AS ds__month , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS ds__quarter @@ -445,7 +445,7 @@ FROM ( , EXTRACT(dow FROM users_latest_src_10021.ds) AS ds__extract_dow , EXTRACT(doy FROM users_latest_src_10021.ds) AS ds__extract_doy , users_latest_src_10021.home_state_latest - , users_latest_src_10021.ds AS user__ds__day + , DATE_TRUNC('day', users_latest_src_10021.ds) AS user__ds__day , DATE_TRUNC('week', users_latest_src_10021.ds) AS user__ds__week , DATE_TRUNC('month', users_latest_src_10021.ds) AS user__ds__month , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS user__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql index feb5ed0fdc..aa2ad14d34 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -13,7 +13,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10015 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql index 1cfb7780a7..a3e98c1218 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0.sql @@ -144,7 +144,7 @@ FROM ( , bookings_source_src_10015.booking_value AS average_booking_value , bookings_source_src_10015.booking_value AS booking_payments , bookings_source_src_10015.is_instant - , bookings_source_src_10015.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter @@ -156,7 +156,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy , bookings_source_src_10015.is_instant AS booking__is_instant - , bookings_source_src_10015.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql index f1b419a284..add7e259ab 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -13,7 +13,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10015 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0.sql index 7e38380b20..18a7c52fef 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multi_join_node__plan0.sql @@ -28,7 +28,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -40,7 +40,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -52,7 +52,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -65,7 +65,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -77,7 +77,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -89,7 +89,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -122,7 +122,7 @@ LEFT OUTER JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -134,7 +134,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -149,7 +149,7 @@ LEFT OUTER JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -161,7 +161,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -196,7 +196,7 @@ LEFT OUTER JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -208,7 +208,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -223,7 +223,7 @@ LEFT OUTER JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -235,7 +235,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql index c742d95f11..5b4b817799 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multihop_node__plan0.sql @@ -99,7 +99,7 @@ FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT account_month_txns_src_10010.txn_count - , account_month_txns_src_10010.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__quarter @@ -111,7 +111,7 @@ FROM ( , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_doy - , account_month_txns_src_10010.ds AS ds__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS ds__day , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS ds__week , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS ds__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS ds__quarter @@ -124,7 +124,7 @@ FROM ( , EXTRACT(dow FROM account_month_txns_src_10010.ds) AS ds__extract_dow , EXTRACT(doy FROM account_month_txns_src_10010.ds) AS ds__extract_doy , account_month_txns_src_10010.account_month - , account_month_txns_src_10010.ds_partitioned AS account_id__ds_partitioned__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__day , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__week , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__quarter @@ -136,7 +136,7 @@ FROM ( , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_day , EXTRACT(dow FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_dow , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , account_month_txns_src_10010.ds AS account_id__ds__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS account_id__ds__day , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS account_id__ds__week , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS account_id__ds__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS account_id__ds__quarter @@ -226,7 +226,7 @@ FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT bridge_table_src_10011.extra_dim - , bridge_table_src_10011.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__quarter @@ -239,7 +239,7 @@ FROM ( , EXTRACT(dow FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_doy , bridge_table_src_10011.extra_dim AS account_id__extra_dim - , bridge_table_src_10011.ds_partitioned AS account_id__ds_partitioned__day + , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__day , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__week , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__month , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__quarter @@ -252,7 +252,7 @@ FROM ( , EXTRACT(dow FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_dow , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_doy , bridge_table_src_10011.extra_dim AS bridge_account__extra_dim - , bridge_table_src_10011.ds_partitioned AS bridge_account__ds_partitioned__day + , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__day , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__week , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__month , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__quarter @@ -337,7 +337,7 @@ FROM ( SELECT customer_table_src_10013.customer_name , customer_table_src_10013.customer_atomic_weight - , customer_table_src_10013.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS ds_partitioned__quarter @@ -351,7 +351,7 @@ FROM ( , EXTRACT(doy FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_doy , customer_table_src_10013.customer_name AS customer_id__customer_name , customer_table_src_10013.customer_atomic_weight AS customer_id__customer_atomic_weight - , customer_table_src_10013.ds_partitioned AS customer_id__ds_partitioned__day + , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__day , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__week , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__month , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql index ba4bf14fba..8a42052413 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multihop_node__plan0_optimized.sql @@ -12,7 +12,7 @@ LEFT OUTER JOIN ( -- Pass Only Elements: -- ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - bridge_table_src_10011.ds_partitioned AS ds_partitioned__day + DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day , bridge_table_src_10011.account_id AS account_id , customer_table_src_10013.customer_name AS customer_id__customer_name FROM ***************************.bridge_table bridge_table_src_10011 @@ -22,14 +22,14 @@ LEFT OUTER JOIN ( ( bridge_table_src_10011.customer_id = customer_table_src_10013.customer_id ) AND ( - bridge_table_src_10011.ds_partitioned = customer_table_src_10013.ds_partitioned + DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) = DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) ) ) subq_18 ON ( account_month_txns_src_10010.account_id = subq_18.account_id ) AND ( - account_month_txns_src_10010.ds_partitioned = subq_18.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) = subq_18.ds_partitioned__day ) GROUP BY subq_18.customer_id__customer_name diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0.sql index 54b108dd33..df6a1ebfc8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0.sql @@ -249,7 +249,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -261,7 +261,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -273,7 +273,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -286,7 +286,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -298,7 +298,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -310,7 +310,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -505,7 +505,7 @@ CROSS JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -517,7 +517,7 @@ CROSS JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -532,7 +532,7 @@ CROSS JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -544,7 +544,7 @@ CROSS JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 74dcbb71f8..56554460d5 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -13,7 +13,7 @@ FROM ( SELECT SUM(1) AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 - WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' + WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-01' ) subq_17 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' @@ -26,5 +26,5 @@ CROSS JOIN ( SELECT SUM(1) AS listings FROM ***************************.dim_listings_latest listings_latest_src_10004 - WHERE created_at BETWEEN '2020-01-01' AND '2020-01-01' + WHERE DATE_TRUNC('day', created_at) BETWEEN '2020-01-01' AND '2020-01-01' ) subq_23 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0.sql index a716977aaf..bd98232377 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0.sql @@ -162,7 +162,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -186,7 +186,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -223,7 +223,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -391,7 +391,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -403,7 +403,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -415,7 +415,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -428,7 +428,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -440,7 +440,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -452,7 +452,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -632,7 +632,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -644,7 +644,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -656,7 +656,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -669,7 +669,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -681,7 +681,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -693,7 +693,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -871,7 +871,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -883,7 +883,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -895,7 +895,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -908,7 +908,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -920,7 +920,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -932,7 +932,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0_optimized.sql index e45cf8bb70..519c4b6ea5 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_nested_derived_metric__plan0_optimized.sql @@ -32,7 +32,7 @@ FROM ( -- Pass Only Elements: -- ['referred_bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_25 @@ -51,7 +51,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_30 @@ -82,7 +82,7 @@ FROM ( -- Pass Only Elements: -- ['instant_bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_37 @@ -111,7 +111,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_42 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0.sql index 68e1d3302c..1d6baffd15 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0_optimized.sql index d1a408e031..cbb1d95f41 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_offset_window_with_date_part__plan0_optimized.sql @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_order_by_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_order_by_node__plan0.sql index d6632b499f..5aaceec9da 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_order_by_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_order_by_node__plan0.sql @@ -40,7 +40,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -52,7 +52,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -64,7 +64,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -77,7 +77,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -89,7 +89,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -101,7 +101,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_order_by_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_order_by_node__plan0_optimized.sql index efe34b261f..b0e38b1d22 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_order_by_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_order_by_node__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'is_instant', 'ds__day'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql index 44cff4ab94..778bddf502 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0.sql @@ -101,7 +101,7 @@ FROM ( -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , id_verifications_src_10003.ds AS ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter @@ -113,7 +113,7 @@ FROM ( , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter @@ -126,7 +126,7 @@ FROM ( , EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy , id_verifications_src_10003.verification_type - , id_verifications_src_10003.ds AS verification__ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter @@ -138,7 +138,7 @@ FROM ( , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS verification__ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT - users_ds_source_src_10007.ds AS ds__day + DATE_TRUNC('day', users_ds_source_src_10007.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS ds__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS ds__quarter @@ -180,7 +180,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.ds) AS ds__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.ds) AS ds__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS ds__extract_doy - , users_ds_source_src_10007.created_at AS created_at__day + , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS created_at__day , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS created_at__week , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS created_at__month , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS created_at__quarter @@ -192,7 +192,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS created_at__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.created_at) AS created_at__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS created_at__extract_doy - , users_ds_source_src_10007.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(dow FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_doy , users_ds_source_src_10007.home_state - , users_ds_source_src_10007.ds AS user__ds__day + , DATE_TRUNC('day', users_ds_source_src_10007.ds) AS user__ds__day , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS user__ds__week , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS user__ds__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS user__ds__quarter @@ -217,7 +217,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.ds) AS user__ds__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.ds) AS user__ds__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS user__ds__extract_doy - , users_ds_source_src_10007.created_at AS user__created_at__day + , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS user__created_at__day , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS user__created_at__week , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS user__created_at__month , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS user__created_at__quarter @@ -229,7 +229,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_doy - , users_ds_source_src_10007.ds_partitioned AS user__ds_partitioned__day + , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__day , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__week , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0_optimized.sql index 66ea172ae7..c15982d861 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_partitioned_join__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( -- Pass Only Elements: -- ['identity_verifications', 'ds_partitioned__day', 'user'] SELECT - ds_partitioned AS ds_partitioned__day + DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications FROM ***************************.fct_id_verifications id_verifications_src_10003 @@ -23,7 +23,7 @@ ON ( subq_10.user = users_ds_source_src_10007.user_id ) AND ( - subq_10.ds_partitioned__day = users_ds_source_src_10007.ds_partitioned + subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) ) GROUP BY users_ds_source_src_10007.home_state diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node__plan0.sql index 33fc914795..6c9249001c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node__plan0.sql @@ -37,7 +37,7 @@ FROM ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter @@ -77,7 +77,7 @@ INNER JOIN ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -90,7 +90,7 @@ INNER JOIN ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node__plan0_optimized.sql index d90abbd294..c35f358f2d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node__plan0_optimized.sql @@ -37,7 +37,7 @@ FROM ( account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy , account_type - , ds AS account__ds__day + , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week , DATE_TRUNC('month', ds) AS account__ds__month , DATE_TRUNC('quarter', ds) AS account__ds__quarter @@ -71,7 +71,7 @@ INNER JOIN ( -- Read Elements From Semantic Model 'accounts_source' -- Filter row on MIN(ds__day) SELECT - MIN(ds) AS ds__day__complete + MIN(DATE_TRUNC('day', ds)) AS ds__day__complete FROM ***************************.fct_accounts accounts_source_src_10000 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_grouping__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_grouping__plan0.sql index dc98b44d95..c98bf2362f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_grouping__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_grouping__plan0.sql @@ -37,7 +37,7 @@ FROM ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter @@ -78,7 +78,7 @@ INNER JOIN ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -91,7 +91,7 @@ INNER JOIN ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_grouping__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_grouping__plan0_optimized.sql index d723157d2a..bb14649634 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_grouping__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_grouping__plan0_optimized.sql @@ -37,7 +37,7 @@ FROM ( account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy , account_type - , ds AS account__ds__day + , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week , DATE_TRUNC('month', ds) AS account__ds__month , DATE_TRUNC('quarter', ds) AS account__ds__quarter @@ -72,7 +72,7 @@ INNER JOIN ( -- Filter row on MAX(ds__day) SELECT user_id AS user - , MAX(ds) AS ds__day__complete + , MAX(DATE_TRUNC('day', ds)) AS ds__day__complete FROM ***************************.fct_accounts accounts_source_src_10000 GROUP BY user_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_queried_group_by__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_queried_group_by__plan0.sql index 95274f2863..d42a779e8d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_queried_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_queried_group_by__plan0.sql @@ -37,7 +37,7 @@ FROM ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter @@ -78,7 +78,7 @@ INNER JOIN ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -91,7 +91,7 @@ INNER JOIN ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql index e0c877bdf1..89c29c7a7f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql @@ -37,7 +37,7 @@ FROM ( account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy , account_type - , ds AS account__ds__day + , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week , DATE_TRUNC('month', ds) AS account__ds__month , DATE_TRUNC('quarter', ds) AS account__ds__quarter @@ -72,7 +72,7 @@ INNER JOIN ( -- Filter row on MIN(ds__day) SELECT DATE_TRUNC('week', ds) AS ds__week - , MIN(ds) AS ds__day__complete + , MIN(DATE_TRUNC('day', ds)) AS ds__day__complete FROM ***************************.fct_accounts accounts_source_src_10000 GROUP BY DATE_TRUNC('week', ds) diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_simple_query_with_date_part__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_simple_query_with_date_part__plan0.sql index 3869c341c5..460694cf59 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_simple_query_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_simple_query_with_date_part__plan0.sql @@ -139,7 +139,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -151,7 +151,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -163,7 +163,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -176,7 +176,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -188,7 +188,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -200,7 +200,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_simple_query_with_multiple_date_parts__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_simple_query_with_multiple_date_parts__plan0.sql index b1321ec748..078ba0df0c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_simple_query_with_multiple_date_parts__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_simple_query_with_multiple_date_parts__plan0.sql @@ -164,7 +164,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -176,7 +176,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -188,7 +188,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -201,7 +201,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -213,7 +213,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -225,7 +225,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0.sql index 9c6e0a2676..7e054cfaa7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_single_join_node__plan0.sql @@ -26,7 +26,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -38,7 +38,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -75,7 +75,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -87,7 +87,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -120,7 +120,7 @@ LEFT OUTER JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -132,7 +132,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -147,7 +147,7 @@ LEFT OUTER JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -159,7 +159,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_source_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_source_node__plan0.sql index b9ae7f84a4..b2741d3532 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_source_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_source_node__plan0.sql @@ -15,7 +15,7 @@ SELECT , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -27,7 +27,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -39,7 +39,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -52,7 +52,7 @@ SELECT , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -64,7 +64,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -76,7 +76,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_source_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_source_node__plan0_optimized.sql index d1560d9ab0..ba6c6f95c0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_source_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Redshift/test_source_node__plan0_optimized.sql @@ -15,7 +15,7 @@ SELECT , booking_value AS approximate_continuous_booking_value_p99 , booking_value AS approximate_discrete_booking_value_p99 , is_instant - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -27,7 +27,7 @@ SELECT , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy - , ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS ds_partitioned__quarter @@ -39,7 +39,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS ds_partitioned__extract_doy - , paid_at AS paid_at__day + , DATE_TRUNC('day', paid_at) AS paid_at__day , DATE_TRUNC('week', paid_at) AS paid_at__week , DATE_TRUNC('month', paid_at) AS paid_at__month , DATE_TRUNC('quarter', paid_at) AS paid_at__quarter @@ -52,7 +52,7 @@ SELECT , EXTRACT(dow FROM paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS paid_at__extract_doy , is_instant AS booking__is_instant - , ds AS booking__ds__day + , DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('week', ds) AS booking__ds__week , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('quarter', ds) AS booking__ds__quarter @@ -64,7 +64,7 @@ SELECT , EXTRACT(day FROM ds) AS booking__ds__extract_day , EXTRACT(dow FROM ds) AS booking__ds__extract_dow , EXTRACT(doy FROM ds) AS booking__ds__extract_doy - , ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS booking__ds_partitioned__quarter @@ -76,7 +76,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS booking__ds_partitioned__extract_doy - , paid_at AS booking__paid_at__day + , DATE_TRUNC('day', paid_at) AS booking__paid_at__day , DATE_TRUNC('week', paid_at) AS booking__paid_at__week , DATE_TRUNC('month', paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_common_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_common_semantic_model__plan0.sql index b954d8927e..202450d6c4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_common_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_common_semantic_model__plan0.sql @@ -145,7 +145,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -157,7 +157,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -182,7 +182,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -374,7 +374,7 @@ FULL OUTER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -386,7 +386,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -398,7 +398,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -411,7 +411,7 @@ FULL OUTER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -423,7 +423,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -435,7 +435,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_common_semantic_model__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_common_semantic_model__plan0_optimized.sql index 6ac18252b5..552b4dc805 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_common_semantic_model__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_common_semantic_model__plan0_optimized.sql @@ -15,7 +15,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_12 @@ -30,11 +30,11 @@ FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) ) subq_19 ON subq_14.metric_time__day = subq_19.metric_time__day diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0.sql index b1bf877e84..2319f07e20 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node__plan0.sql @@ -39,7 +39,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -51,7 +51,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -76,7 +76,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -88,7 +88,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -100,7 +100,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -133,7 +133,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -145,7 +145,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -160,7 +160,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql index 5373f3b9a9..3114cb4fc6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.sql @@ -169,7 +169,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -218,7 +218,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -230,7 +230,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -339,7 +339,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -351,7 +351,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -366,7 +366,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -378,7 +378,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -514,7 +514,7 @@ FROM ( -- Read Elements From Semantic Model 'views_source' SELECT 1 AS views - , views_source_src_10009.ds AS ds__day + , DATE_TRUNC('day', views_source_src_10009.ds) AS ds__day , DATE_TRUNC('week', views_source_src_10009.ds) AS ds__week , DATE_TRUNC('month', views_source_src_10009.ds) AS ds__month , DATE_TRUNC('quarter', views_source_src_10009.ds) AS ds__quarter @@ -526,7 +526,7 @@ FROM ( , EXTRACT(day FROM views_source_src_10009.ds) AS ds__extract_day , EXTRACT(dow FROM views_source_src_10009.ds) AS ds__extract_dow , EXTRACT(doy FROM views_source_src_10009.ds) AS ds__extract_doy - , views_source_src_10009.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS ds_partitioned__quarter @@ -538,7 +538,7 @@ FROM ( , EXTRACT(day FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM views_source_src_10009.ds_partitioned) AS ds_partitioned__extract_doy - , views_source_src_10009.ds AS view__ds__day + , DATE_TRUNC('day', views_source_src_10009.ds) AS view__ds__day , DATE_TRUNC('week', views_source_src_10009.ds) AS view__ds__week , DATE_TRUNC('month', views_source_src_10009.ds) AS view__ds__month , DATE_TRUNC('quarter', views_source_src_10009.ds) AS view__ds__quarter @@ -550,7 +550,7 @@ FROM ( , EXTRACT(day FROM views_source_src_10009.ds) AS view__ds__extract_day , EXTRACT(dow FROM views_source_src_10009.ds) AS view__ds__extract_dow , EXTRACT(doy FROM views_source_src_10009.ds) AS view__ds__extract_doy - , views_source_src_10009.ds_partitioned AS view__ds_partitioned__day + , DATE_TRUNC('day', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__day , DATE_TRUNC('week', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__week , DATE_TRUNC('month', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__month , DATE_TRUNC('quarter', views_source_src_10009.ds_partitioned) AS view__ds_partitioned__quarter @@ -657,7 +657,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -669,7 +669,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -684,7 +684,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -696,7 +696,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql index 02295e403e..03f2aa3d7e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'ds__day', 'listing'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 @@ -49,7 +49,7 @@ INNER JOIN ( -- Pass Only Elements: -- ['views', 'ds__day', 'listing'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , listing_id AS listing , 1 AS views FROM ***************************.fct_views views_source_src_10009 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql index 1bd176c115..e5b6875b78 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.sql @@ -42,7 +42,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -54,7 +54,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -66,7 +66,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -79,7 +79,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -91,7 +91,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -103,7 +103,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -136,7 +136,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -148,7 +148,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -163,7 +163,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -175,7 +175,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0.sql index cd879426f7..a90f9421e2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_compute_metrics_node_simple_expr__plan0.sql @@ -39,7 +39,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -51,7 +51,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -76,7 +76,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -88,7 +88,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -100,7 +100,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -133,7 +133,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -145,7 +145,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -160,7 +160,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_constrain_time_range_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_constrain_time_range_node__plan0.sql index 5b6dd99cc4..b274191665 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_constrain_time_range_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_constrain_time_range_node__plan0.sql @@ -33,7 +33,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -45,7 +45,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -57,7 +57,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -70,7 +70,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -82,7 +82,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -94,7 +94,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_constrain_time_range_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_constrain_time_range_node__plan0_optimized.sql index bfc4959615..207fa171fa 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_constrain_time_range_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_constrain_time_range_node__plan0_optimized.sql @@ -4,8 +4,8 @@ -- Metric Time Dimension 'ds' -- Constrain Time Range to [2020-01-01T00:00:00, 2020-01-02T00:00:00] SELECT - ds AS ds__day - , ds AS metric_time__day + DATE_TRUNC('day', ds) AS ds__day + , DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 -WHERE ds BETWEEN '2020-01-01' AND '2020-01-02' +WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-02' diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0.sql index 6920a36691..3b92bc016a 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric__plan0.sql @@ -59,7 +59,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -71,7 +71,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0.sql index 4080ab9420..b843616ed0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_grain_to_date__plan0.sql @@ -59,7 +59,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -71,7 +71,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0.sql index fcf74a5947..5ef2c1add0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_ds__plan0.sql @@ -56,7 +56,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -68,7 +68,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0.sql index 0143335613..5db12c7b97 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window__plan0.sql @@ -59,7 +59,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -71,7 +71,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql index 5cba3a3202..4a950ee81d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0.sql @@ -101,7 +101,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -113,7 +113,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql index c420ef636f..dfc97e9ec9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_no_window_with_time_constraint__plan0_optimized.sql @@ -9,6 +9,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS revenue_all_time FROM ***************************.fct_revenue revenue_src_10006 -WHERE created_at BETWEEN '2000-01-01' AND '2020-01-01' +WHERE DATE_TRUNC('day', created_at) BETWEEN '2000-01-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql index 414159089b..375f61a3f6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0.sql @@ -101,7 +101,7 @@ FROM ( -- Read Elements From Semantic Model 'revenue' SELECT revenue_src_10006.revenue AS txn_revenue - , revenue_src_10006.created_at AS ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS ds__quarter @@ -113,7 +113,7 @@ FROM ( , EXTRACT(day FROM revenue_src_10006.created_at) AS ds__extract_day , EXTRACT(dow FROM revenue_src_10006.created_at) AS ds__extract_dow , EXTRACT(doy FROM revenue_src_10006.created_at) AS ds__extract_doy - , revenue_src_10006.created_at AS company__ds__day + , DATE_TRUNC('day', revenue_src_10006.created_at) AS company__ds__day , DATE_TRUNC('week', revenue_src_10006.created_at) AS company__ds__week , DATE_TRUNC('month', revenue_src_10006.created_at) AS company__ds__month , DATE_TRUNC('quarter', revenue_src_10006.created_at) AS company__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql index e3387b51e4..c78471782b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_cumulative_metric_with_time_constraint__plan0_optimized.sql @@ -9,6 +9,6 @@ SELECT DATE_TRUNC('month', created_at) AS ds__month , SUM(revenue) AS trailing_2_months_revenue FROM ***************************.fct_revenue revenue_src_10006 -WHERE created_at BETWEEN '2019-12-01' AND '2020-01-01' +WHERE DATE_TRUNC('day', created_at) BETWEEN '2019-12-01' AND '2020-01-01' GROUP BY DATE_TRUNC('month', created_at) diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0.sql index 5b4011175d..bebcd049ee 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -379,7 +379,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -391,7 +391,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -403,7 +403,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -416,7 +416,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -428,7 +428,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -440,7 +440,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0_optimized.sql index 336e7623a6..ace6863100 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['referred_bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_13 @@ -39,7 +39,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_18 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql index d11a69936d..090069e6fb 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0_optimized.sql index 425f3c5f99..a952516e96 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_16 @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index b98d6d0f3d..73b332fea3 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql index b458c826f3..e5a7e1789c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_to_grain_and_granularity__plan0_optimized.sql @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql index 9139bc862d..8461e53fc4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0_optimized.sql index 80c5452e0d..d79d809654 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_16 @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 0022a4f526..d840b06e43 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql index c5d0b45b69..bbdb2547b7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_granularity__plan0_optimized.sql @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index 10bb6c0450..a6df144424 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -253,7 +253,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -265,7 +265,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -277,7 +277,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -290,7 +290,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -302,7 +302,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -314,7 +314,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -588,7 +588,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -600,7 +600,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -612,7 +612,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -625,7 +625,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -637,7 +637,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -649,7 +649,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql index fb585a52b9..3f57ba0cbf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain__plan0_optimized.sql @@ -22,7 +22,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_18 @@ -45,7 +45,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_26 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index 1aaa96b40a..4b45c0edc7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -253,7 +253,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -265,7 +265,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -277,7 +277,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -290,7 +290,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -302,7 +302,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -314,7 +314,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -589,7 +589,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -601,7 +601,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -613,7 +613,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -626,7 +626,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -638,7 +638,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -650,7 +650,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql index 966f139fe1..40dd779220 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0_optimized.sql @@ -22,7 +22,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_18 @@ -46,7 +46,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_26 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0.sql index 3107752f3d..9c5c91984c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0.sql @@ -361,7 +361,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -373,7 +373,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -385,7 +385,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -398,7 +398,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -410,7 +410,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -422,7 +422,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0_optimized.sql index b99a126d9b..9609d10b3f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_offset_cumulative_metric__plan0_optimized.sql @@ -22,9 +22,9 @@ FROM ( ***************************.fct_bookings bookings_source_src_10001 ON ( - bookings_source_src_10001.ds <= subq_14.ds + DATE_TRUNC('day', bookings_source_src_10001.ds) <= subq_14.ds ) AND ( - bookings_source_src_10001.ds > DATEADD(day, -2, subq_14.ds) + DATE_TRUNC('day', bookings_source_src_10001.ds) > DATEADD(day, -2, subq_14.ds) ) ) subq_15 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0.sql index 666e2d3376..0ea424f256 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -247,7 +247,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -259,7 +259,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -271,7 +271,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -284,7 +284,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -296,7 +296,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -308,7 +308,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql index 43a78551de..5ede4be6d6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_derived_offset_metric_with_one_input_metric__plan0_optimized.sql @@ -16,7 +16,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_9 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0.sql index 40f6785af3..86ba05d2c1 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_distinct_values__plan0.sql @@ -160,7 +160,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -184,7 +184,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -197,7 +197,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -209,7 +209,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -221,7 +221,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -330,7 +330,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -342,7 +342,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -357,7 +357,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -369,7 +369,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_node__plan0.sql index a43457fcbd..eaa8fb6dcf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_node__plan0.sql @@ -20,7 +20,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -32,7 +32,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -44,7 +44,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -57,7 +57,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -69,7 +69,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -81,7 +81,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_node__plan0.sql index a3ce23fb89..4f2da7c5cf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_node__plan0.sql @@ -26,7 +26,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -38,7 +38,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -75,7 +75,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -87,7 +87,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_node__plan0_optimized.sql index c850362ca3..98241721ca 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_node__plan0_optimized.sql @@ -7,7 +7,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'ds__day'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_3 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0.sql index 70919d8caa..0022e1d7c4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_filter_with_where_constraint_on_join_dim__plan0.sql @@ -166,7 +166,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -178,7 +178,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -190,7 +190,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -203,7 +203,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -215,7 +215,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -227,7 +227,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -336,7 +336,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -348,7 +348,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -363,7 +363,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -375,7 +375,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0.sql index 6e4488a729..b8f50cd3cf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0.sql @@ -154,7 +154,7 @@ FROM ( , bookings_source_src_10015.booking_value AS average_booking_value , bookings_source_src_10015.booking_value AS booking_payments , bookings_source_src_10015.is_instant - , bookings_source_src_10015.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter @@ -166,7 +166,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter @@ -178,7 +178,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter @@ -191,7 +191,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy , bookings_source_src_10015.is_instant AS booking__is_instant - , bookings_source_src_10015.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter @@ -203,7 +203,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter @@ -215,7 +215,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0_optimized.sql index 86a2010b35..db1199fc2e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_scd_dimension__plan0_optimized.sql @@ -20,7 +20,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10015 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql index 9f23719b49..3a106515f6 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0.sql @@ -155,7 +155,7 @@ INNER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -167,7 +167,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -179,7 +179,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -192,7 +192,7 @@ INNER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -204,7 +204,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -216,7 +216,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql index 6a4ced8cd8..d0748a2ddb 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_to_grain__plan0_optimized.sql @@ -23,12 +23,12 @@ INNER JOIN ( -- ['booking_value', 'metric_time__day', 'listing'] -- Aggregate Measures SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) , listing_id ) subq_10 ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0.sql index 1c6b0467ff..29d0ec4e19 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0.sql @@ -155,7 +155,7 @@ INNER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -167,7 +167,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -179,7 +179,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -192,7 +192,7 @@ INNER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -204,7 +204,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -216,7 +216,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql index f5c740c47c..cc0dcc2828 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_with_offset_window__plan0_optimized.sql @@ -23,12 +23,12 @@ INNER JOIN ( -- ['booking_value', 'metric_time__day', 'listing'] -- Aggregate Measures SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) , listing_id ) subq_10 ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0.sql index 2093e49b0b..457449a984 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0.sql @@ -155,7 +155,7 @@ INNER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -167,7 +167,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -179,7 +179,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -192,7 +192,7 @@ INNER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -204,7 +204,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -216,7 +216,7 @@ INNER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0_optimized.sql index 4afadfc929..26398b9d40 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_join_to_time_spine_node_without_offset__plan0_optimized.sql @@ -23,12 +23,12 @@ INNER JOIN ( -- ['booking_value', 'metric_time__day', 'listing'] -- Aggregate Measures SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) , listing_id ) subq_10 ) subq_11 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_limit_rows__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_limit_rows__plan0.sql index eb506ddf59..7fd977201f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_limit_rows__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_limit_rows__plan0.sql @@ -144,7 +144,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -156,7 +156,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_limit_rows__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_limit_rows__plan0_optimized.sql index 6db56759fc..e52871ff7c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_limit_rows__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_limit_rows__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'ds__day'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_7 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0.sql index d5688f0e2d..2ff36d921e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_local_dimension_using_local_entity__plan0.sql @@ -94,7 +94,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -106,7 +106,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -121,7 +121,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -133,7 +133,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_aggregation_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_aggregation_node__plan0.sql index dbfcb34b94..7ebbd78174 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_aggregation_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_aggregation_node__plan0.sql @@ -30,7 +30,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -42,7 +42,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -54,7 +54,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -67,7 +67,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -79,7 +79,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -91,7 +91,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql index e5349b0d17..961480acb5 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0.sql @@ -178,7 +178,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -190,7 +190,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -202,7 +202,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -215,7 +215,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -227,7 +227,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -239,7 +239,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -348,7 +348,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -360,7 +360,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -375,7 +375,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -387,7 +387,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -589,7 +589,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -601,7 +601,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -613,7 +613,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -626,7 +626,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -638,7 +638,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -650,7 +650,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -759,7 +759,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -771,7 +771,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -786,7 +786,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -798,7 +798,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -983,7 +983,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -995,7 +995,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -1007,7 +1007,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -1020,7 +1020,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -1032,7 +1032,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -1044,7 +1044,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0_optimized.sql index eb22b75d5e..bf23abb3af 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint__plan0_optimized.sql @@ -23,7 +23,7 @@ FROM ( -- Pass Only Elements: -- ['average_booking_value', 'listing__is_lux_latest', 'metric_time__day'] SELECT - bookings_source_src_10001.ds AS metric_time__day + DATE_TRUNC('day', bookings_source_src_10001.ds) AS metric_time__day , listings_latest_src_10004.is_lux AS listing__is_lux_latest , bookings_source_src_10001.booking_value AS average_booking_value FROM ***************************.fct_bookings bookings_source_src_10001 @@ -59,7 +59,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 @@ -91,11 +91,11 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) ) subq_58 ON ( diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql index c11754db0d..b955d8e418 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0.sql @@ -163,7 +163,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -175,7 +175,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -200,7 +200,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -212,7 +212,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -224,7 +224,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -395,7 +395,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -407,7 +407,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -419,7 +419,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -432,7 +432,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -444,7 +444,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -456,7 +456,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0_optimized.sql index 7c202ae455..36878b678c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_reused_measure__plan0_optimized.sql @@ -18,7 +18,7 @@ FROM ( -- Pass Only Elements: -- ['booking_value', 'booking__is_instant', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , booking_value FROM ***************************.fct_bookings bookings_source_src_10001 @@ -35,11 +35,11 @@ INNER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , SUM(booking_value) AS booking_value FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - ds + DATE_TRUNC('day', ds) ) subq_24 ON ( diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0.sql index bd41d48bd9..58e129bcbe 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0.sql @@ -157,7 +157,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -218,7 +218,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql index c012c97a59..18094198a4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_measure_constraint_with_single_expr_and_alias__plan0_optimized.sql @@ -17,7 +17,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'booking__is_instant', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , is_instant AS booking__is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql index ecc15101fe..b9e841c10f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.sql @@ -145,7 +145,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -157,7 +157,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -182,7 +182,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -324,7 +324,7 @@ FROM ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -336,7 +336,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -351,7 +351,7 @@ FROM ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -363,7 +363,7 @@ FROM ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql index 79946c1bc1..16fde28343 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0.sql @@ -144,7 +144,7 @@ FROM ( , bookings_source_src_10015.booking_value AS average_booking_value , bookings_source_src_10015.booking_value AS booking_payments , bookings_source_src_10015.is_instant - , bookings_source_src_10015.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter @@ -156,7 +156,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy , bookings_source_src_10015.is_instant AS booking__is_instant - , bookings_source_src_10015.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter @@ -432,7 +432,7 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_latest' SELECT - users_latest_src_10021.ds AS ds__day + DATE_TRUNC('day', users_latest_src_10021.ds) AS ds__day , DATE_TRUNC('week', users_latest_src_10021.ds) AS ds__week , DATE_TRUNC('month', users_latest_src_10021.ds) AS ds__month , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS ds__quarter @@ -445,7 +445,7 @@ FROM ( , EXTRACT(dow FROM users_latest_src_10021.ds) AS ds__extract_dow , EXTRACT(doy FROM users_latest_src_10021.ds) AS ds__extract_doy , users_latest_src_10021.home_state_latest - , users_latest_src_10021.ds AS user__ds__day + , DATE_TRUNC('day', users_latest_src_10021.ds) AS user__ds__day , DATE_TRUNC('week', users_latest_src_10021.ds) AS user__ds__week , DATE_TRUNC('month', users_latest_src_10021.ds) AS user__ds__month , DATE_TRUNC('quarter', users_latest_src_10021.ds) AS user__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql index feb5ed0fdc..aa2ad14d34 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_hop_through_scd_dimension__plan0_optimized.sql @@ -13,7 +13,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10015 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql index 1cfb7780a7..a3e98c1218 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0.sql @@ -144,7 +144,7 @@ FROM ( , bookings_source_src_10015.booking_value AS average_booking_value , bookings_source_src_10015.booking_value AS booking_payments , bookings_source_src_10015.is_instant - , bookings_source_src_10015.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS ds__quarter @@ -156,7 +156,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS paid_at__quarter @@ -181,7 +181,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10015.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.paid_at) AS paid_at__extract_doy , bookings_source_src_10015.is_instant AS booking__is_instant - , bookings_source_src_10015.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10015.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10015.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10015.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds) AS booking__ds__quarter @@ -193,7 +193,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds) AS booking__ds__extract_doy - , bookings_source_src_10015.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10015.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10015.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10015.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10015.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10015.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10015.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql index f1b419a284..add7e259ab 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_hop_to_scd_dimension__plan0_optimized.sql @@ -13,7 +13,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day', 'listing'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , listing_id AS listing , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10015 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0.sql index 7e38380b20..18a7c52fef 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multi_join_node__plan0.sql @@ -28,7 +28,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -40,7 +40,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -52,7 +52,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -65,7 +65,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -77,7 +77,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -89,7 +89,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -122,7 +122,7 @@ LEFT OUTER JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -134,7 +134,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -149,7 +149,7 @@ LEFT OUTER JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -161,7 +161,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter @@ -196,7 +196,7 @@ LEFT OUTER JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -208,7 +208,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -223,7 +223,7 @@ LEFT OUTER JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -235,7 +235,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql index c742d95f11..5b4b817799 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0.sql @@ -99,7 +99,7 @@ FROM ( -- Read Elements From Semantic Model 'account_month_txns' SELECT account_month_txns_src_10010.txn_count - , account_month_txns_src_10010.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__quarter @@ -111,7 +111,7 @@ FROM ( , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS ds_partitioned__extract_doy - , account_month_txns_src_10010.ds AS ds__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS ds__day , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS ds__week , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS ds__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS ds__quarter @@ -124,7 +124,7 @@ FROM ( , EXTRACT(dow FROM account_month_txns_src_10010.ds) AS ds__extract_dow , EXTRACT(doy FROM account_month_txns_src_10010.ds) AS ds__extract_doy , account_month_txns_src_10010.account_month - , account_month_txns_src_10010.ds_partitioned AS account_id__ds_partitioned__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__day , DATE_TRUNC('week', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__week , DATE_TRUNC('month', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__quarter @@ -136,7 +136,7 @@ FROM ( , EXTRACT(day FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_day , EXTRACT(dow FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_dow , EXTRACT(doy FROM account_month_txns_src_10010.ds_partitioned) AS account_id__ds_partitioned__extract_doy - , account_month_txns_src_10010.ds AS account_id__ds__day + , DATE_TRUNC('day', account_month_txns_src_10010.ds) AS account_id__ds__day , DATE_TRUNC('week', account_month_txns_src_10010.ds) AS account_id__ds__week , DATE_TRUNC('month', account_month_txns_src_10010.ds) AS account_id__ds__month , DATE_TRUNC('quarter', account_month_txns_src_10010.ds) AS account_id__ds__quarter @@ -226,7 +226,7 @@ FROM ( -- Read Elements From Semantic Model 'bridge_table' SELECT bridge_table_src_10011.extra_dim - , bridge_table_src_10011.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__quarter @@ -239,7 +239,7 @@ FROM ( , EXTRACT(dow FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS ds_partitioned__extract_doy , bridge_table_src_10011.extra_dim AS account_id__extra_dim - , bridge_table_src_10011.ds_partitioned AS account_id__ds_partitioned__day + , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__day , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__week , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__month , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__quarter @@ -252,7 +252,7 @@ FROM ( , EXTRACT(dow FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_dow , EXTRACT(doy FROM bridge_table_src_10011.ds_partitioned) AS account_id__ds_partitioned__extract_doy , bridge_table_src_10011.extra_dim AS bridge_account__extra_dim - , bridge_table_src_10011.ds_partitioned AS bridge_account__ds_partitioned__day + , DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__day , DATE_TRUNC('week', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__week , DATE_TRUNC('month', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__month , DATE_TRUNC('quarter', bridge_table_src_10011.ds_partitioned) AS bridge_account__ds_partitioned__quarter @@ -337,7 +337,7 @@ FROM ( SELECT customer_table_src_10013.customer_name , customer_table_src_10013.customer_atomic_weight - , customer_table_src_10013.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS ds_partitioned__quarter @@ -351,7 +351,7 @@ FROM ( , EXTRACT(doy FROM customer_table_src_10013.ds_partitioned) AS ds_partitioned__extract_doy , customer_table_src_10013.customer_name AS customer_id__customer_name , customer_table_src_10013.customer_atomic_weight AS customer_id__customer_atomic_weight - , customer_table_src_10013.ds_partitioned AS customer_id__ds_partitioned__day + , DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__day , DATE_TRUNC('week', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__week , DATE_TRUNC('month', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__month , DATE_TRUNC('quarter', customer_table_src_10013.ds_partitioned) AS customer_id__ds_partitioned__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql index ba4bf14fba..8a42052413 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multihop_node__plan0_optimized.sql @@ -12,7 +12,7 @@ LEFT OUTER JOIN ( -- Pass Only Elements: -- ['customer_id__customer_name', 'ds_partitioned__day', 'account_id'] SELECT - bridge_table_src_10011.ds_partitioned AS ds_partitioned__day + DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) AS ds_partitioned__day , bridge_table_src_10011.account_id AS account_id , customer_table_src_10013.customer_name AS customer_id__customer_name FROM ***************************.bridge_table bridge_table_src_10011 @@ -22,14 +22,14 @@ LEFT OUTER JOIN ( ( bridge_table_src_10011.customer_id = customer_table_src_10013.customer_id ) AND ( - bridge_table_src_10011.ds_partitioned = customer_table_src_10013.ds_partitioned + DATE_TRUNC('day', bridge_table_src_10011.ds_partitioned) = DATE_TRUNC('day', customer_table_src_10013.ds_partitioned) ) ) subq_18 ON ( account_month_txns_src_10010.account_id = subq_18.account_id ) AND ( - account_month_txns_src_10010.ds_partitioned = subq_18.ds_partitioned__day + DATE_TRUNC('day', account_month_txns_src_10010.ds_partitioned) = subq_18.ds_partitioned__day ) GROUP BY subq_18.customer_id__customer_name diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0.sql index 54b108dd33..df6a1ebfc8 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0.sql @@ -249,7 +249,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -261,7 +261,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -273,7 +273,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -286,7 +286,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -298,7 +298,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -310,7 +310,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -505,7 +505,7 @@ CROSS JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -517,7 +517,7 @@ CROSS JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -532,7 +532,7 @@ CROSS JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -544,7 +544,7 @@ CROSS JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0_optimized.sql index 74dcbb71f8..56554460d5 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_multiple_metrics_no_dimensions__plan0_optimized.sql @@ -13,7 +13,7 @@ FROM ( SELECT SUM(1) AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 - WHERE ds BETWEEN '2020-01-01' AND '2020-01-01' + WHERE DATE_TRUNC('day', ds) BETWEEN '2020-01-01' AND '2020-01-01' ) subq_17 CROSS JOIN ( -- Read Elements From Semantic Model 'listings_latest' @@ -26,5 +26,5 @@ CROSS JOIN ( SELECT SUM(1) AS listings FROM ***************************.dim_listings_latest listings_latest_src_10004 - WHERE created_at BETWEEN '2020-01-01' AND '2020-01-01' + WHERE DATE_TRUNC('day', created_at) BETWEEN '2020-01-01' AND '2020-01-01' ) subq_23 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0.sql index a716977aaf..bd98232377 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0.sql @@ -162,7 +162,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -186,7 +186,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -223,7 +223,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -391,7 +391,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -403,7 +403,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -415,7 +415,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -428,7 +428,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -440,7 +440,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -452,7 +452,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -632,7 +632,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -644,7 +644,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -656,7 +656,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -669,7 +669,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -681,7 +681,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -693,7 +693,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -871,7 +871,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -883,7 +883,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -895,7 +895,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -908,7 +908,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -920,7 +920,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -932,7 +932,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0_optimized.sql index e45cf8bb70..519c4b6ea5 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_nested_derived_metric__plan0_optimized.sql @@ -32,7 +32,7 @@ FROM ( -- Pass Only Elements: -- ['referred_bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN referrer_id IS NOT NULL THEN 1 ELSE 0 END AS referred_bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_25 @@ -51,7 +51,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_30 @@ -82,7 +82,7 @@ FROM ( -- Pass Only Elements: -- ['instant_bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , CASE WHEN is_instant THEN 1 ELSE 0 END AS instant_bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_37 @@ -111,7 +111,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_42 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0.sql index 68e1d3302c..1d6baffd15 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0.sql @@ -150,7 +150,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -162,7 +162,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -174,7 +174,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -187,7 +187,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -199,7 +199,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -211,7 +211,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -482,7 +482,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -494,7 +494,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -506,7 +506,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -519,7 +519,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -531,7 +531,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -543,7 +543,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0_optimized.sql index d1a408e031..cbb1d95f41 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_offset_window_with_date_part__plan0_optimized.sql @@ -41,7 +41,7 @@ FROM ( -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_20 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_order_by_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_order_by_node__plan0.sql index d6632b499f..5aaceec9da 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_order_by_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_order_by_node__plan0.sql @@ -40,7 +40,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -52,7 +52,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -64,7 +64,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -77,7 +77,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -89,7 +89,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -101,7 +101,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_order_by_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_order_by_node__plan0_optimized.sql index efe34b261f..b0e38b1d22 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_order_by_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_order_by_node__plan0_optimized.sql @@ -10,7 +10,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'is_instant', 'ds__day'] SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , is_instant , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql index 44cff4ab94..778bddf502 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0.sql @@ -101,7 +101,7 @@ FROM ( -- Read Elements From Semantic Model 'id_verifications' SELECT 1 AS identity_verifications - , id_verifications_src_10003.ds AS ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS ds__quarter @@ -113,7 +113,7 @@ FROM ( , EXTRACT(day FROM id_verifications_src_10003.ds) AS ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS ds_partitioned__quarter @@ -126,7 +126,7 @@ FROM ( , EXTRACT(dow FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds_partitioned) AS ds_partitioned__extract_doy , id_verifications_src_10003.verification_type - , id_verifications_src_10003.ds AS verification__ds__day + , DATE_TRUNC('day', id_verifications_src_10003.ds) AS verification__ds__day , DATE_TRUNC('week', id_verifications_src_10003.ds) AS verification__ds__week , DATE_TRUNC('month', id_verifications_src_10003.ds) AS verification__ds__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds) AS verification__ds__quarter @@ -138,7 +138,7 @@ FROM ( , EXTRACT(day FROM id_verifications_src_10003.ds) AS verification__ds__extract_day , EXTRACT(dow FROM id_verifications_src_10003.ds) AS verification__ds__extract_dow , EXTRACT(doy FROM id_verifications_src_10003.ds) AS verification__ds__extract_doy - , id_verifications_src_10003.ds_partitioned AS verification__ds_partitioned__day + , DATE_TRUNC('day', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__day , DATE_TRUNC('week', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__week , DATE_TRUNC('month', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__month , DATE_TRUNC('quarter', id_verifications_src_10003.ds_partitioned) AS verification__ds_partitioned__quarter @@ -168,7 +168,7 @@ FROM ( FROM ( -- Read Elements From Semantic Model 'users_ds_source' SELECT - users_ds_source_src_10007.ds AS ds__day + DATE_TRUNC('day', users_ds_source_src_10007.ds) AS ds__day , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS ds__week , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS ds__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS ds__quarter @@ -180,7 +180,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.ds) AS ds__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.ds) AS ds__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS ds__extract_doy - , users_ds_source_src_10007.created_at AS created_at__day + , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS created_at__day , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS created_at__week , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS created_at__month , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS created_at__quarter @@ -192,7 +192,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS created_at__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.created_at) AS created_at__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS created_at__extract_doy - , users_ds_source_src_10007.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__quarter @@ -205,7 +205,7 @@ FROM ( , EXTRACT(dow FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.ds_partitioned) AS ds_partitioned__extract_doy , users_ds_source_src_10007.home_state - , users_ds_source_src_10007.ds AS user__ds__day + , DATE_TRUNC('day', users_ds_source_src_10007.ds) AS user__ds__day , DATE_TRUNC('week', users_ds_source_src_10007.ds) AS user__ds__week , DATE_TRUNC('month', users_ds_source_src_10007.ds) AS user__ds__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds) AS user__ds__quarter @@ -217,7 +217,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.ds) AS user__ds__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.ds) AS user__ds__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.ds) AS user__ds__extract_doy - , users_ds_source_src_10007.created_at AS user__created_at__day + , DATE_TRUNC('day', users_ds_source_src_10007.created_at) AS user__created_at__day , DATE_TRUNC('week', users_ds_source_src_10007.created_at) AS user__created_at__week , DATE_TRUNC('month', users_ds_source_src_10007.created_at) AS user__created_at__month , DATE_TRUNC('quarter', users_ds_source_src_10007.created_at) AS user__created_at__quarter @@ -229,7 +229,7 @@ FROM ( , EXTRACT(day FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_day , EXTRACT(dow FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_dow , EXTRACT(doy FROM users_ds_source_src_10007.created_at) AS user__created_at__extract_doy - , users_ds_source_src_10007.ds_partitioned AS user__ds_partitioned__day + , DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__day , DATE_TRUNC('week', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__week , DATE_TRUNC('month', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__month , DATE_TRUNC('quarter', users_ds_source_src_10007.ds_partitioned) AS user__ds_partitioned__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0_optimized.sql index 66ea172ae7..c15982d861 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_partitioned_join__plan0_optimized.sql @@ -12,7 +12,7 @@ FROM ( -- Pass Only Elements: -- ['identity_verifications', 'ds_partitioned__day', 'user'] SELECT - ds_partitioned AS ds_partitioned__day + DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , user_id AS user , 1 AS identity_verifications FROM ***************************.fct_id_verifications id_verifications_src_10003 @@ -23,7 +23,7 @@ ON ( subq_10.user = users_ds_source_src_10007.user_id ) AND ( - subq_10.ds_partitioned__day = users_ds_source_src_10007.ds_partitioned + subq_10.ds_partitioned__day = DATE_TRUNC('day', users_ds_source_src_10007.ds_partitioned) ) GROUP BY users_ds_source_src_10007.home_state diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node__plan0.sql index 33fc914795..6c9249001c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node__plan0.sql @@ -37,7 +37,7 @@ FROM ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter @@ -77,7 +77,7 @@ INNER JOIN ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -90,7 +90,7 @@ INNER JOIN ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node__plan0_optimized.sql index d90abbd294..c35f358f2d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node__plan0_optimized.sql @@ -37,7 +37,7 @@ FROM ( account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy , account_type - , ds AS account__ds__day + , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week , DATE_TRUNC('month', ds) AS account__ds__month , DATE_TRUNC('quarter', ds) AS account__ds__quarter @@ -71,7 +71,7 @@ INNER JOIN ( -- Read Elements From Semantic Model 'accounts_source' -- Filter row on MIN(ds__day) SELECT - MIN(ds) AS ds__day__complete + MIN(DATE_TRUNC('day', ds)) AS ds__day__complete FROM ***************************.fct_accounts accounts_source_src_10000 ) subq_5 ON diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_grouping__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_grouping__plan0.sql index dc98b44d95..c98bf2362f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_grouping__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_grouping__plan0.sql @@ -37,7 +37,7 @@ FROM ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter @@ -78,7 +78,7 @@ INNER JOIN ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -91,7 +91,7 @@ INNER JOIN ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_grouping__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_grouping__plan0_optimized.sql index d723157d2a..bb14649634 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_grouping__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_grouping__plan0_optimized.sql @@ -37,7 +37,7 @@ FROM ( account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy , account_type - , ds AS account__ds__day + , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week , DATE_TRUNC('month', ds) AS account__ds__month , DATE_TRUNC('quarter', ds) AS account__ds__quarter @@ -72,7 +72,7 @@ INNER JOIN ( -- Filter row on MAX(ds__day) SELECT user_id AS user - , MAX(ds) AS ds__day__complete + , MAX(DATE_TRUNC('day', ds)) AS ds__day__complete FROM ***************************.fct_accounts accounts_source_src_10000 GROUP BY user_id diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_queried_group_by__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_queried_group_by__plan0.sql index 95274f2863..d42a779e8d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_queried_group_by__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_queried_group_by__plan0.sql @@ -37,7 +37,7 @@ FROM ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter @@ -78,7 +78,7 @@ INNER JOIN ( accounts_source_src_10000.account_balance , accounts_source_src_10000.account_balance AS total_account_balance_first_day , accounts_source_src_10000.account_balance AS current_account_balance_by_user - , accounts_source_src_10000.ds AS ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS ds__quarter @@ -91,7 +91,7 @@ INNER JOIN ( , EXTRACT(dow FROM accounts_source_src_10000.ds) AS ds__extract_dow , EXTRACT(doy FROM accounts_source_src_10000.ds) AS ds__extract_doy , accounts_source_src_10000.account_type - , accounts_source_src_10000.ds AS account__ds__day + , DATE_TRUNC('day', accounts_source_src_10000.ds) AS account__ds__day , DATE_TRUNC('week', accounts_source_src_10000.ds) AS account__ds__week , DATE_TRUNC('month', accounts_source_src_10000.ds) AS account__ds__month , DATE_TRUNC('quarter', accounts_source_src_10000.ds) AS account__ds__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql index e0c877bdf1..89c29c7a7f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_semi_additive_join_node_with_queried_group_by__plan0_optimized.sql @@ -37,7 +37,7 @@ FROM ( account_balance , account_balance AS total_account_balance_first_day , account_balance AS current_account_balance_by_user - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy , account_type - , ds AS account__ds__day + , DATE_TRUNC('day', ds) AS account__ds__day , DATE_TRUNC('week', ds) AS account__ds__week , DATE_TRUNC('month', ds) AS account__ds__month , DATE_TRUNC('quarter', ds) AS account__ds__quarter @@ -72,7 +72,7 @@ INNER JOIN ( -- Filter row on MIN(ds__day) SELECT DATE_TRUNC('week', ds) AS ds__week - , MIN(ds) AS ds__day__complete + , MIN(DATE_TRUNC('day', ds)) AS ds__day__complete FROM ***************************.fct_accounts accounts_source_src_10000 GROUP BY DATE_TRUNC('week', ds) diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_simple_query_with_date_part__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_simple_query_with_date_part__plan0.sql index 3869c341c5..460694cf59 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_simple_query_with_date_part__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_simple_query_with_date_part__plan0.sql @@ -139,7 +139,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -151,7 +151,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -163,7 +163,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -176,7 +176,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -188,7 +188,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -200,7 +200,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_simple_query_with_multiple_date_parts__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_simple_query_with_multiple_date_parts__plan0.sql index b1321ec748..078ba0df0c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_simple_query_with_multiple_date_parts__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_simple_query_with_multiple_date_parts__plan0.sql @@ -164,7 +164,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -176,7 +176,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -188,7 +188,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -201,7 +201,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -213,7 +213,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -225,7 +225,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0.sql index 9c6e0a2676..7e054cfaa7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_single_join_node__plan0.sql @@ -26,7 +26,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -38,7 +38,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -50,7 +50,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -63,7 +63,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -75,7 +75,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -87,7 +87,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -120,7 +120,7 @@ LEFT OUTER JOIN ( 1 AS listings , listings_latest_src_10004.capacity AS largest_listing , listings_latest_src_10004.capacity AS smallest_listing - , listings_latest_src_10004.created_at AS ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS ds__quarter @@ -132,7 +132,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS ds__extract_doy - , listings_latest_src_10004.created_at AS created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS created_at__quarter @@ -147,7 +147,7 @@ LEFT OUTER JOIN ( , listings_latest_src_10004.country AS country_latest , listings_latest_src_10004.is_lux AS is_lux_latest , listings_latest_src_10004.capacity AS capacity_latest - , listings_latest_src_10004.created_at AS listing__ds__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__ds__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__ds__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__ds__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__ds__quarter @@ -159,7 +159,7 @@ LEFT OUTER JOIN ( , EXTRACT(day FROM listings_latest_src_10004.created_at) AS listing__ds__extract_day , EXTRACT(dow FROM listings_latest_src_10004.created_at) AS listing__ds__extract_dow , EXTRACT(doy FROM listings_latest_src_10004.created_at) AS listing__ds__extract_doy - , listings_latest_src_10004.created_at AS listing__created_at__day + , DATE_TRUNC('day', listings_latest_src_10004.created_at) AS listing__created_at__day , DATE_TRUNC('week', listings_latest_src_10004.created_at) AS listing__created_at__week , DATE_TRUNC('month', listings_latest_src_10004.created_at) AS listing__created_at__month , DATE_TRUNC('quarter', listings_latest_src_10004.created_at) AS listing__created_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_source_node__plan0.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_source_node__plan0.sql index b9ae7f84a4..b2741d3532 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_source_node__plan0.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_source_node__plan0.sql @@ -15,7 +15,7 @@ SELECT , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -27,7 +27,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -39,7 +39,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -52,7 +52,7 @@ SELECT , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -64,7 +64,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -76,7 +76,7 @@ SELECT , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_source_node__plan0_optimized.sql b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_source_node__plan0_optimized.sql index d1560d9ab0..ba6c6f95c0 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_source_node__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/Snowflake/test_source_node__plan0_optimized.sql @@ -15,7 +15,7 @@ SELECT , booking_value AS approximate_continuous_booking_value_p99 , booking_value AS approximate_discrete_booking_value_p99 , is_instant - , ds AS ds__day + , DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -27,7 +27,7 @@ SELECT , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy - , ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS ds_partitioned__quarter @@ -39,7 +39,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS ds_partitioned__extract_doy - , paid_at AS paid_at__day + , DATE_TRUNC('day', paid_at) AS paid_at__day , DATE_TRUNC('week', paid_at) AS paid_at__week , DATE_TRUNC('month', paid_at) AS paid_at__month , DATE_TRUNC('quarter', paid_at) AS paid_at__quarter @@ -52,7 +52,7 @@ SELECT , EXTRACT(dow FROM paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS paid_at__extract_doy , is_instant AS booking__is_instant - , ds AS booking__ds__day + , DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('week', ds) AS booking__ds__week , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('quarter', ds) AS booking__ds__quarter @@ -64,7 +64,7 @@ SELECT , EXTRACT(day FROM ds) AS booking__ds__extract_day , EXTRACT(dow FROM ds) AS booking__ds__extract_dow , EXTRACT(doy FROM ds) AS booking__ds__extract_doy - , ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS booking__ds_partitioned__quarter @@ -76,7 +76,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS booking__ds_partitioned__extract_doy - , paid_at AS booking__paid_at__day + , DATE_TRUNC('day', paid_at) AS booking__paid_at__day , DATE_TRUNC('week', paid_at) AS booking__paid_at__week , DATE_TRUNC('month', paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_common_semantic_model__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_common_semantic_model__plan0.xml index d5208d36cf..af2705f5a3 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_common_semantic_model__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_common_semantic_model__plan0.xml @@ -559,25 +559,25 @@ - - - - + + + + - + - + - + - + @@ -607,25 +607,25 @@ - - - - + + + + - + - + - + - + @@ -655,25 +655,25 @@ - - - - + + + + - + - + - + - + @@ -707,25 +707,25 @@ - - - - + + + + - + - + - + - + @@ -755,25 +755,25 @@ - - - - + + + + - + - + - + - + @@ -803,25 +803,25 @@ - - - - + + + + - + - + - + - + @@ -1420,25 +1420,25 @@ - - - - + + + + - + - + - + - + @@ -1468,25 +1468,25 @@ - - - - + + + + - + - + - + - + @@ -1516,25 +1516,25 @@ - - - - + + + + - + - + - + - + @@ -1568,25 +1568,25 @@ - - - - + + + + - + - + - + - + @@ -1616,25 +1616,25 @@ - - - - + + + + - + - + - + - + @@ -1664,25 +1664,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node__plan0.xml index 2660580f8d..6a70da8347 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node__plan0.xml @@ -142,25 +142,25 @@ - - - - + + + + - + - + - + - + @@ -190,25 +190,25 @@ - - - - + + + + - + - + - + - + @@ -238,25 +238,25 @@ - - - - + + + + - + - + - + - + @@ -290,25 +290,25 @@ - - - - + + + + - + - + - + - + @@ -338,25 +338,25 @@ - - - - + + + + - + - + - + - + @@ -386,25 +386,25 @@ - - - - + + + + - + - + - + - + @@ -497,25 +497,25 @@ - - - - + + + + - + - + - + - + @@ -545,25 +545,25 @@ - - - - + + + + - + - + - + - + @@ -605,25 +605,25 @@ - - - - + + + + - + - + - + - + @@ -653,25 +653,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml index 543c84a88f..8c49763d87 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml @@ -638,25 +638,25 @@ - - - - + + + + - + - + - + - + @@ -686,25 +686,25 @@ - - - - + + + + - + - + - + - + @@ -734,25 +734,25 @@ - - - - + + + + - + - + - + - + @@ -786,25 +786,25 @@ - - - - + + + + - + - + - + - + @@ -834,25 +834,25 @@ - - - - + + + + - + - + - + - + @@ -882,25 +882,25 @@ - - - - + + + + - + - + - + - + @@ -1287,25 +1287,25 @@ - - - - + + + + - + - + - + - + @@ -1335,25 +1335,25 @@ - - - - + + + + - + - + - + - + @@ -1395,25 +1395,25 @@ - - - - + + + + - + - + - + - + @@ -1443,25 +1443,25 @@ - - - - + + + + - + - + - + - + @@ -1908,25 +1908,25 @@ - - - - + + + + - + - + - + - + @@ -1956,25 +1956,25 @@ - - - - + + + + - + - + - + - + @@ -2004,25 +2004,25 @@ - - - - + + + + - + - + - + - + @@ -2052,25 +2052,25 @@ - - - - + + + + - + - + - + - + @@ -2449,25 +2449,25 @@ - - - - + + + + - + - + - + - + @@ -2497,25 +2497,25 @@ - - - - + + + + - + - + - + - + @@ -2557,25 +2557,25 @@ - - - - + + + + - + - + - + - + @@ -2605,25 +2605,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.xml index 9caab95d18..cb94533d16 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.xml @@ -154,25 +154,25 @@ - - - - + + + + - + - + - + - + @@ -202,25 +202,25 @@ - - - - + + + + - + - + - + - + @@ -250,25 +250,25 @@ - - - - + + + + - + - + - + - + @@ -302,25 +302,25 @@ - - - - + + + + - + - + - + - + @@ -350,25 +350,25 @@ - - - - + + + + - + - + - + - + @@ -398,25 +398,25 @@ - - - - + + + + - + - + - + - + @@ -509,25 +509,25 @@ - - - - + + + + - + - + - + - + @@ -557,25 +557,25 @@ - - - - + + + + - + - + - + - + @@ -617,25 +617,25 @@ - - - - + + + + - + - + - + - + @@ -665,25 +665,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_simple_expr__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_simple_expr__plan0.xml index 5510083da3..9844515c5d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_simple_expr__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_simple_expr__plan0.xml @@ -142,25 +142,25 @@ - - - - + + + + - + - + - + - + @@ -190,25 +190,25 @@ - - - - + + + + - + - + - + - + @@ -238,25 +238,25 @@ - - - - + + + + - + - + - + - + @@ -290,25 +290,25 @@ - - - - + + + + - + - + - + - + @@ -338,25 +338,25 @@ - - - - + + + + - + - + - + - + @@ -386,25 +386,25 @@ - - - - + + + + - + - + - + - + @@ -497,25 +497,25 @@ - - - - + + + + - + - + - + - + @@ -545,25 +545,25 @@ - - - - + + + + - + - + - + - + @@ -605,25 +605,25 @@ - - - - + + + + - + - + - + - + @@ -653,25 +653,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_constrain_time_range_node__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_constrain_time_range_node__plan0.xml index 6832ab1d88..e87c730528 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_constrain_time_range_node__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_constrain_time_range_node__plan0.xml @@ -112,25 +112,25 @@ - - - - + + + + - + - + - + - + @@ -160,25 +160,25 @@ - - - - + + + + - + - + - + - + @@ -208,25 +208,25 @@ - - - - + + + + - + - + - + - + @@ -260,25 +260,25 @@ - - - - + + + + - + - + - + - + @@ -308,25 +308,25 @@ - - - - + + + + - + - + - + - + @@ -356,25 +356,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric__plan0.xml index 6a4f2968b1..7c973fc4cb 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric__plan0.xml @@ -212,25 +212,25 @@ - - - - + + + + - + - + - + - + @@ -260,25 +260,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_grain_to_date__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_grain_to_date__plan0.xml index 05e69c0c94..019ac8e6f2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_grain_to_date__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_grain_to_date__plan0.xml @@ -212,25 +212,25 @@ - - - - + + + + - + - + - + - + @@ -260,25 +260,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_no_ds__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_no_ds__plan0.xml index c44152f685..f17e5cc1b9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_no_ds__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_no_ds__plan0.xml @@ -196,25 +196,25 @@ - - - - + + + + - + - + - + - + @@ -244,25 +244,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_no_window__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_no_window__plan0.xml index c246fb55db..810f27e6a2 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_no_window__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_no_window__plan0.xml @@ -212,25 +212,25 @@ - - - - + + + + - + - + - + - + @@ -260,25 +260,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_no_window_with_time_constraint__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_no_window_with_time_constraint__plan0.xml index 11c4a6ef28..834412ce23 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_no_window_with_time_constraint__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_no_window_with_time_constraint__plan0.xml @@ -374,25 +374,25 @@ - - - - + + + + - + - + - + - + @@ -422,25 +422,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_with_time_constraint__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_with_time_constraint__plan0.xml index 69648ea206..dee1cf3bf5 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_with_time_constraint__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_cumulative_metric_with_time_constraint__plan0.xml @@ -374,25 +374,25 @@ - - - - + + + + - + - + - + - + @@ -422,25 +422,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric__plan0.xml index c527d74a06..e35a85c77b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric__plan0.xml @@ -568,25 +568,25 @@ - - - - + + + + - + - + - + - + @@ -616,25 +616,25 @@ - - - - + + + + - + - + - + - + @@ -664,25 +664,25 @@ - - - - + + + + - + - + - + - + @@ -716,25 +716,25 @@ - - - - + + + + - + - + - + - + @@ -764,25 +764,25 @@ - - - - + + + + - + - + - + - + @@ -812,25 +812,25 @@ - - - - + + + + - + - + - + - + @@ -1429,25 +1429,25 @@ - - - - + + + + - + - + - + - + @@ -1477,25 +1477,25 @@ - - - - + + + + - + - + - + - + @@ -1525,25 +1525,25 @@ - - - - + + + + - + - + - + - + @@ -1577,25 +1577,25 @@ - - - - + + + + - + - + - + - + @@ -1625,25 +1625,25 @@ - - - - + + + + - + - + - + - + @@ -1673,25 +1673,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_to_grain__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_to_grain__plan0.xml index d35dd96911..cfc96a25cb 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_to_grain__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_to_grain__plan0.xml @@ -568,25 +568,25 @@ - - - - + + + + - + - + - + - + @@ -616,25 +616,25 @@ - - - - + + + + - + - + - + - + @@ -664,25 +664,25 @@ - - - - + + + + - + - + - + - + @@ -716,25 +716,25 @@ - - - - + + + + - + - + - + - + @@ -764,25 +764,25 @@ - - - - + + + + - + - + - + - + @@ -812,25 +812,25 @@ - - - - + + + + - + - + - + - + @@ -1831,25 +1831,25 @@ - - - - + + + + - + - + - + - + @@ -1879,25 +1879,25 @@ - - - - + + + + - + - + - + - + @@ -1927,25 +1927,25 @@ - - - - + + + + - + - + - + - + @@ -1979,25 +1979,25 @@ - - - - + + + + - + - + - + - + @@ -2027,25 +2027,25 @@ - - - - + + + + - + - + - + - + @@ -2075,25 +2075,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_to_grain_and_granularity__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_to_grain_and_granularity__plan0.xml index 6b48478444..3ab902ac38 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_to_grain_and_granularity__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_to_grain_and_granularity__plan0.xml @@ -568,25 +568,25 @@ - - - - + + + + - + - + - + - + @@ -616,25 +616,25 @@ - - - - + + + + - + - + - + - + @@ -664,25 +664,25 @@ - - - - + + + + - + - + - + - + @@ -716,25 +716,25 @@ - - - - + + + + - + - + - + - + @@ -764,25 +764,25 @@ - - - - + + + + - + - + - + - + @@ -812,25 +812,25 @@ - - - - + + + + - + - + - + - + @@ -1831,25 +1831,25 @@ - - - - + + + + - + - + - + - + @@ -1879,25 +1879,25 @@ - - - - + + + + - + - + - + - + @@ -1927,25 +1927,25 @@ - - - - + + + + - + - + - + - + @@ -1979,25 +1979,25 @@ - - - - + + + + - + - + - + - + @@ -2027,25 +2027,25 @@ - - - - + + + + - + - + - + - + @@ -2075,25 +2075,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_window__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_window__plan0.xml index 5b50744b8e..9318abe781 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_window__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_window__plan0.xml @@ -568,25 +568,25 @@ - - - - + + + + - + - + - + - + @@ -616,25 +616,25 @@ - - - - + + + + - + - + - + - + @@ -664,25 +664,25 @@ - - - - + + + + - + - + - + - + @@ -716,25 +716,25 @@ - - - - + + + + - + - + - + - + @@ -764,25 +764,25 @@ - - - - + + + + - + - + - + - + @@ -812,25 +812,25 @@ - - - - + + + + - + - + - + - + @@ -1831,25 +1831,25 @@ - - - - + + + + - + - + - + - + @@ -1879,25 +1879,25 @@ - - - - + + + + - + - + - + - + @@ -1927,25 +1927,25 @@ - - - - + + + + - + - + - + - + @@ -1979,25 +1979,25 @@ - - - - + + + + - + - + - + - + @@ -2027,25 +2027,25 @@ - - - - + + + + - + - + - + - + @@ -2075,25 +2075,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_window_and_granularity__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_window_and_granularity__plan0.xml index ec4e79d22a..ab43119fbe 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_window_and_granularity__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_window_and_granularity__plan0.xml @@ -568,25 +568,25 @@ - - - - + + + + - + - + - + - + @@ -616,25 +616,25 @@ - - - - + + + + - + - + - + - + @@ -664,25 +664,25 @@ - - - - + + + + - + - + - + - + @@ -716,25 +716,25 @@ - - - - + + + + - + - + - + - + @@ -764,25 +764,25 @@ - - - - + + + + - + - + - + - + @@ -812,25 +812,25 @@ - - - - + + + + - + - + - + - + @@ -1831,25 +1831,25 @@ - - - - + + + + - + - + - + - + @@ -1879,25 +1879,25 @@ - - - - + + + + - + - + - + - + @@ -1927,25 +1927,25 @@ - - - - + + + + - + - + - + - + @@ -1979,25 +1979,25 @@ - - - - + + + + - + - + - + - + @@ -2027,25 +2027,25 @@ - - - - + + + + - + - + - + - + @@ -2075,25 +2075,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.xml index 1014811f94..148285d345 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.xml @@ -970,25 +970,25 @@ - - - - + + + + - + - + - + - + @@ -1018,25 +1018,25 @@ - - - - + + + + - + - + - + - + @@ -1066,25 +1066,25 @@ - - - - + + + + - + - + - + - + @@ -1118,25 +1118,25 @@ - - - - + + + + - + - + - + - + @@ -1166,25 +1166,25 @@ - - - - + + + + - + - + - + - + @@ -1214,25 +1214,25 @@ - - - - + + + + - + - + - + - + @@ -2234,25 +2234,25 @@ - - - - + + + + - + - + - + - + @@ -2282,25 +2282,25 @@ - - - - + + + + - + - + - + - + @@ -2330,25 +2330,25 @@ - - - - + + + + - + - + - + - + @@ -2382,25 +2382,25 @@ - - - - + + + + - + - + - + - + @@ -2430,25 +2430,25 @@ - - - - + + + + - + - + - + - + @@ -2478,25 +2478,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.xml index db25cedbd2..48cd50e78c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.xml @@ -970,25 +970,25 @@ - - - - + + + + - + - + - + - + @@ -1018,25 +1018,25 @@ - - - - + + + + - + - + - + - + @@ -1066,25 +1066,25 @@ - - - - + + + + - + - + - + - + @@ -1118,25 +1118,25 @@ - - - - + + + + - + - + - + - + @@ -1166,25 +1166,25 @@ - - - - + + + + - + - + - + - + @@ -1214,25 +1214,25 @@ - - - - + + + + - + - + - + - + @@ -2234,25 +2234,25 @@ - - - - + + + + - + - + - + - + @@ -2282,25 +2282,25 @@ - - - - + + + + - + - + - + - + @@ -2330,25 +2330,25 @@ - - - - + + + + - + - + - + - + @@ -2382,25 +2382,25 @@ - - - - + + + + - + - + - + - + @@ -2430,25 +2430,25 @@ - - - - + + + + - + - + - + - + @@ -2478,25 +2478,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_offset_cumulative_metric__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_offset_cumulative_metric__plan0.xml index 91104c0b88..efdcc495b3 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_offset_cumulative_metric__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_offset_cumulative_metric__plan0.xml @@ -1393,25 +1393,25 @@ - - - - + + + + - + - + - + - + @@ -1441,25 +1441,25 @@ - - - - + + + + - + - + - + - + @@ -1489,25 +1489,25 @@ - - - - + + + + - + - + - + - + @@ -1541,25 +1541,25 @@ - - - - + + + + - + - + - + - + @@ -1589,25 +1589,25 @@ - - - - + + + + - + - + - + - + @@ -1637,25 +1637,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_offset_metric_with_one_input_metric__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_offset_metric_with_one_input_metric__plan0.xml index 9ebd2f147b..ce8067f7a9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_offset_metric_with_one_input_metric__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_derived_offset_metric_with_one_input_metric__plan0.xml @@ -947,25 +947,25 @@ - - - - + + + + - + - + - + - + @@ -995,25 +995,25 @@ - - - - + + + + - + - + - + - + @@ -1043,25 +1043,25 @@ - - - - + + + + - + - + - + - + @@ -1095,25 +1095,25 @@ - - - - + + + + - + - + - + - + @@ -1143,25 +1143,25 @@ - - - - + + + + - + - + - + - + @@ -1191,25 +1191,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_distinct_values__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_distinct_values__plan0.xml index 919417183e..ac358b0579 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_distinct_values__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_distinct_values__plan0.xml @@ -594,25 +594,25 @@ - - - - + + + + - + - + - + - + @@ -642,25 +642,25 @@ - - - - + + + + - + - + - + - + @@ -690,25 +690,25 @@ - - - - + + + + - + - + - + - + @@ -742,25 +742,25 @@ - - - - + + + + - + - + - + - + @@ -790,25 +790,25 @@ - - - - + + + + - + - + - + - + @@ -838,25 +838,25 @@ - - - - + + + + - + - + - + - + @@ -1243,25 +1243,25 @@ - - - - + + + + - + - + - + - + @@ -1291,25 +1291,25 @@ - - - - + + + + - + - + - + - + @@ -1351,25 +1351,25 @@ - - - - + + + + - + - + - + - + @@ -1399,25 +1399,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_node__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_node__plan0.xml index aba5cdf553..eb5a5aa055 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_node__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_node__plan0.xml @@ -73,25 +73,25 @@ - - - - + + + + - + - + - + - + @@ -121,25 +121,25 @@ - - - - + + + + - + - + - + - + @@ -169,25 +169,25 @@ - - - - + + + + - + - + - + - + @@ -221,25 +221,25 @@ - - - - + + + + - + - + - + - + @@ -269,25 +269,25 @@ - - - - + + + + - + - + - + - + @@ -317,25 +317,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_with_where_constraint_node__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_with_where_constraint_node__plan0.xml index 81fcf21f1b..b731940e5c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_with_where_constraint_node__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_with_where_constraint_node__plan0.xml @@ -91,25 +91,25 @@ - - - - + + + + - + - + - + - + @@ -139,25 +139,25 @@ - - - - + + + + - + - + - + - + @@ -187,25 +187,25 @@ - - - - + + + + - + - + - + - + @@ -239,25 +239,25 @@ - - - - + + + + - + - + - + - + @@ -287,25 +287,25 @@ - - - - + + + + - + - + - + - + @@ -335,25 +335,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_with_where_constraint_on_join_dim__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_with_where_constraint_on_join_dim__plan0.xml index ea3ee863e4..cb74387e16 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_with_where_constraint_on_join_dim__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_with_where_constraint_on_join_dim__plan0.xml @@ -615,25 +615,25 @@ - - - - + + + + - + - + - + - + @@ -663,25 +663,25 @@ - - - - + + + + - + - + - + - + @@ -711,25 +711,25 @@ - - - - + + + + - + - + - + - + @@ -763,25 +763,25 @@ - - - - + + + + - + - + - + - + @@ -811,25 +811,25 @@ - - - - + + + + - + - + - + - + @@ -859,25 +859,25 @@ - - - - + + + + - + - + - + - + @@ -1264,25 +1264,25 @@ - - - - + + + + - + - + - + - + @@ -1312,25 +1312,25 @@ - - - - + + + + - + - + - + - + @@ -1372,25 +1372,25 @@ - - - - + + + + - + - + - + - + @@ -1420,25 +1420,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_scd_dimension__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_scd_dimension__plan0.xml index 6072f1480d..72e82b6fa7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_scd_dimension__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_scd_dimension__plan0.xml @@ -567,25 +567,25 @@ - - - - + + + + - + - + - + - + @@ -615,25 +615,25 @@ - - - - + + + + - + - + - + - + @@ -663,25 +663,25 @@ - - - - + + + + - + - + - + - + @@ -715,25 +715,25 @@ - - - - + + + + - + - + - + - + @@ -763,25 +763,25 @@ - - - - + + + + - + - + - + - + @@ -811,25 +811,25 @@ - - - - + + + + - + - + - + - + @@ -933,19 +933,19 @@ - + - + - + - + @@ -981,19 +981,19 @@ - + - + - + - + @@ -1041,19 +1041,19 @@ - + - + - + - + @@ -1089,19 +1089,19 @@ - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_with_offset_to_grain__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_with_offset_to_grain__plan0.xml index 6c3d99f0d6..896a2a11db 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_with_offset_to_grain__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_with_offset_to_grain__plan0.xml @@ -586,25 +586,25 @@ - - - - + + + + - + - + - + - + @@ -634,25 +634,25 @@ - - - - + + + + - + - + - + - + @@ -682,25 +682,25 @@ - - - - + + + + - + - + - + - + @@ -734,25 +734,25 @@ - - - - + + + + - + - + - + - + @@ -782,25 +782,25 @@ - - - - + + + + - + - + - + - + @@ -830,25 +830,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_with_offset_window__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_with_offset_window__plan0.xml index 6c3d99f0d6..896a2a11db 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_with_offset_window__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_with_offset_window__plan0.xml @@ -586,25 +586,25 @@ - - - - + + + + - + - + - + - + @@ -634,25 +634,25 @@ - - - - + + + + - + - + - + - + @@ -682,25 +682,25 @@ - - - - + + + + - + - + - + - + @@ -734,25 +734,25 @@ - - - - + + + + - + - + - + - + @@ -782,25 +782,25 @@ - - - - + + + + - + - + - + - + @@ -830,25 +830,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_without_offset__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_without_offset__plan0.xml index 6c3d99f0d6..896a2a11db 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_without_offset__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_without_offset__plan0.xml @@ -586,25 +586,25 @@ - - - - + + + + - + - + - + - + @@ -634,25 +634,25 @@ - - - - + + + + - + - + - + - + @@ -682,25 +682,25 @@ - - - - + + + + - + - + - + - + @@ -734,25 +734,25 @@ - - - - + + + + - + - + - + - + @@ -782,25 +782,25 @@ - - - - + + + + - + - + - + - + @@ -830,25 +830,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_limit_rows__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_limit_rows__plan0.xml index af7fd91535..cb6c7c4251 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_limit_rows__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_limit_rows__plan0.xml @@ -545,25 +545,25 @@ - - - - + + + + - + - + - + - + @@ -593,25 +593,25 @@ - - - - + + + + - + - + - + - + @@ -641,25 +641,25 @@ - - - - + + + + - + - + - + - + @@ -693,25 +693,25 @@ - - - - + + + + - + - + - + - + @@ -741,25 +741,25 @@ - - - - + + + + - + - + - + - + @@ -789,25 +789,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_local_dimension_using_local_entity__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_local_dimension_using_local_entity__plan0.xml index e0c553b7cb..79eb2fd44b 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_local_dimension_using_local_entity__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_local_dimension_using_local_entity__plan0.xml @@ -352,25 +352,25 @@ - - - - + + + + - + - + - + - + @@ -400,25 +400,25 @@ - - - - + + + + - + - + - + - + @@ -460,25 +460,25 @@ - - - - + + + + - + - + - + - + @@ -508,25 +508,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_aggregation_node__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_aggregation_node__plan0.xml index 9927bd6230..28f0b870e7 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_aggregation_node__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_aggregation_node__plan0.xml @@ -106,25 +106,25 @@ - - - - + + + + - + - + - + - + @@ -154,25 +154,25 @@ - - - - + + + + - + - + - + - + @@ -202,25 +202,25 @@ - - - - + + + + - + - + - + - + @@ -254,25 +254,25 @@ - - - - + + + + - + - + - + - + @@ -302,25 +302,25 @@ - - - - + + + + - + - + - + - + @@ -350,25 +350,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_constraint__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_constraint__plan0.xml index 1b93709a92..92ac8b3681 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_constraint__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_constraint__plan0.xml @@ -661,25 +661,25 @@ - - - - + + + + - + - + - + - + @@ -709,25 +709,25 @@ - - - - + + + + - + - + - + - + @@ -757,25 +757,25 @@ - - - - + + + + - + - + - + - + @@ -809,25 +809,25 @@ - - - - + + + + - + - + - + - + @@ -857,25 +857,25 @@ - - - - + + + + - + - + - + - + @@ -905,25 +905,25 @@ - - - - + + + + - + - + - + - + @@ -1310,25 +1310,25 @@ - - - - + + + + - + - + - + - + @@ -1358,25 +1358,25 @@ - - - - + + + + - + - + - + - + @@ -1418,25 +1418,25 @@ - - - - + + + + - + - + - + - + @@ -1466,25 +1466,25 @@ - - - - + + + + - + - + - + - + @@ -2170,25 +2170,25 @@ - - - - + + + + - + - + - + - + @@ -2218,25 +2218,25 @@ - - - - + + + + - + - + - + - + @@ -2266,25 +2266,25 @@ - - - - + + + + - + - + - + - + @@ -2318,25 +2318,25 @@ - - - - + + + + - + - + - + - + @@ -2366,25 +2366,25 @@ - - - - + + + + - + - + - + - + @@ -2414,25 +2414,25 @@ - - - - + + + + - + - + - + - + @@ -2819,25 +2819,25 @@ - - - - + + + + - + - + - + - + @@ -2867,25 +2867,25 @@ - - - - + + + + - + - + - + - + @@ -2927,25 +2927,25 @@ - - - - + + + + - + - + - + - + @@ -2975,25 +2975,25 @@ - - - - + + + + - + - + - + - + @@ -3596,25 +3596,25 @@ - - - - + + + + - + - + - + - + @@ -3644,25 +3644,25 @@ - - - - + + + + - + - + - + - + @@ -3692,25 +3692,25 @@ - - - - + + + + - + - + - + - + @@ -3744,25 +3744,25 @@ - - - - + + + + - + - + - + - + @@ -3792,25 +3792,25 @@ - - - - + + + + - + - + - + - + @@ -3840,25 +3840,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_constraint_with_reused_measure__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_constraint_with_reused_measure__plan0.xml index f3d68efd51..eac4feac70 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_constraint_with_reused_measure__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_constraint_with_reused_measure__plan0.xml @@ -605,25 +605,25 @@ - - - - + + + + - + - + - + - + @@ -653,25 +653,25 @@ - - - - + + + + - + - + - + - + @@ -701,25 +701,25 @@ - - - - + + + + - + - + - + - + @@ -753,25 +753,25 @@ - - - - + + + + - + - + - + - + @@ -801,25 +801,25 @@ - - - - + + + + - + - + - + - + @@ -849,25 +849,25 @@ - - - - + + + + - + - + - + - + @@ -1468,25 +1468,25 @@ - - - - + + + + - + - + - + - + @@ -1516,25 +1516,25 @@ - - - - + + + + - + - + - + - + @@ -1564,25 +1564,25 @@ - - - - + + + + - + - + - + - + @@ -1616,25 +1616,25 @@ - - - - + + + + - + - + - + - + @@ -1664,25 +1664,25 @@ - - - - + + + + - + - + - + - + @@ -1712,25 +1712,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_constraint_with_single_expr_and_alias__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_constraint_with_single_expr_and_alias__plan0.xml index 7380884768..809c541f8f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_constraint_with_single_expr_and_alias__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_constraint_with_single_expr_and_alias__plan0.xml @@ -582,25 +582,25 @@ - - - - + + + + - + - + - + - + @@ -630,25 +630,25 @@ - - - - + + + + - + - + - + - + @@ -678,25 +678,25 @@ - - - - + + + + - + - + - + - + @@ -730,25 +730,25 @@ - - - - + + + + - + - + - + - + @@ -778,25 +778,25 @@ - - - - + + + + - + - + - + - + @@ -826,25 +826,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.xml index 7b5ea95fa3..d397e41732 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_metric_with_measures_from_multiple_sources_no_dimensions__plan0.xml @@ -544,25 +544,25 @@ - - - - + + + + - + - + - + - + @@ -592,25 +592,25 @@ - - - - + + + + - + - + - + - + @@ -640,25 +640,25 @@ - - - - + + + + - + - + - + - + @@ -692,25 +692,25 @@ - - - - + + + + - + - + - + - + @@ -740,25 +740,25 @@ - - - - + + + + - + - + - + - + @@ -788,25 +788,25 @@ - - - - + + + + - + - + - + - + @@ -1209,25 +1209,25 @@ - - - - + + + + - + - + - + - + @@ -1257,25 +1257,25 @@ - - - - + + + + - + - + - + - + @@ -1317,25 +1317,25 @@ - - - - + + + + - + - + - + - + @@ -1365,25 +1365,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_hop_through_scd_dimension__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_hop_through_scd_dimension__plan0.xml index 8bdf2ed4b4..632940d33c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_hop_through_scd_dimension__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_hop_through_scd_dimension__plan0.xml @@ -546,25 +546,25 @@ - - - - + + + + - + - + - + - + @@ -594,25 +594,25 @@ - - - - + + + + - + - + - + - + @@ -642,25 +642,25 @@ - - - - + + + + - + - + - + - + @@ -694,25 +694,25 @@ - - - - + + + + - + - + - + - + @@ -742,25 +742,25 @@ - - - - + + + + - + - + - + - + @@ -790,25 +790,25 @@ - - - - + + + + - + - + - + - + @@ -1203,19 +1203,19 @@ - + - + - + - + @@ -1251,19 +1251,19 @@ - + - + - + - + @@ -1311,19 +1311,19 @@ - + - + - + - + @@ -1359,19 +1359,19 @@ - + - + - + - + @@ -1577,25 +1577,25 @@ - - - - + + + + - + - + - + - + @@ -1629,25 +1629,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_hop_to_scd_dimension__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_hop_to_scd_dimension__plan0.xml index 54f4173efc..9718b4fe8d 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_hop_to_scd_dimension__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_hop_to_scd_dimension__plan0.xml @@ -546,25 +546,25 @@ - - - - + + + + - + - + - + - + @@ -594,25 +594,25 @@ - - - - + + + + - + - + - + - + @@ -642,25 +642,25 @@ - - - - + + + + - + - + - + - + @@ -694,25 +694,25 @@ - - - - + + + + - + - + - + - + @@ -742,25 +742,25 @@ - - - - + + + + - + - + - + - + @@ -790,25 +790,25 @@ - - - - + + + + - + - + - + - + @@ -1323,19 +1323,19 @@ - + - + - + - + @@ -1371,19 +1371,19 @@ - + - + - + - + @@ -1423,19 +1423,19 @@ - + - + - + - + @@ -1471,19 +1471,19 @@ - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_join_node__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_join_node__plan0.xml index 5fc98dd938..5a816bf44c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_join_node__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_join_node__plan0.xml @@ -110,25 +110,25 @@ - - - - + + + + - + - + - + - + @@ -158,25 +158,25 @@ - - - - + + + + - + - + - + - + @@ -206,25 +206,25 @@ - - - - + + + + - + - + - + - + @@ -258,25 +258,25 @@ - - - - + + + + - + - + - + - + @@ -306,25 +306,25 @@ - - - - + + + + - + - + - + - + @@ -354,25 +354,25 @@ - - - - + + + + - + - + - + - + @@ -465,25 +465,25 @@ - - - - + + + + - + - + - + - + @@ -513,25 +513,25 @@ - - - - + + + + - + - + - + - + @@ -573,25 +573,25 @@ - - - - + + + + - + - + - + - + @@ -621,25 +621,25 @@ - - - - + + + + - + - + - + - + @@ -732,25 +732,25 @@ - - - - + + + + - + - + - + - + @@ -780,25 +780,25 @@ - - - - + + + + - + - + - + - + @@ -840,25 +840,25 @@ - - - - + + + + - + - + - + - + @@ -888,25 +888,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multihop_node__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multihop_node__plan0.xml index 371989c2c7..57e6df9192 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multihop_node__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multihop_node__plan0.xml @@ -362,25 +362,25 @@ - - - - + + + + - + - + - + - + @@ -410,25 +410,25 @@ - - - - + + + + - + - + - + - + @@ -462,25 +462,25 @@ - - - - + + + + - + - + - + - + @@ -510,25 +510,25 @@ - - - - + + + + - + - + - + - + @@ -845,25 +845,25 @@ - - - - + + + + - + - + - + - + @@ -897,25 +897,25 @@ - - - - + + + + - + - + - + - + @@ -949,25 +949,25 @@ - - - - + + + + - + - + - + - + @@ -1187,25 +1187,25 @@ - - - - + + + + - + - + - + - + @@ -1243,25 +1243,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multiple_metrics_no_dimensions__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multiple_metrics_no_dimensions__plan0.xml index 3ad305b7ab..99dea8379f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multiple_metrics_no_dimensions__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multiple_metrics_no_dimensions__plan0.xml @@ -961,25 +961,25 @@ - - - - + + + + - + - + - + - + @@ -1009,25 +1009,25 @@ - - - - + + + + - + - + - + - + @@ -1057,25 +1057,25 @@ - - - - + + + + - + - + - + - + @@ -1109,25 +1109,25 @@ - - - - + + + + - + - + - + - + @@ -1157,25 +1157,25 @@ - - - - + + + + - + - + - + - + @@ -1205,25 +1205,25 @@ - - - - + + + + - + - + - + - + @@ -1921,25 +1921,25 @@ - - - - + + + + - + - + - + - + @@ -1969,25 +1969,25 @@ - - - - + + + + - + - + - + - + @@ -2029,25 +2029,25 @@ - - - - + + + + - + - + - + - + @@ -2077,25 +2077,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_nested_derived_metric__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_nested_derived_metric__plan0.xml index 5a9299184c..ea61cc98a9 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_nested_derived_metric__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_nested_derived_metric__plan0.xml @@ -614,25 +614,25 @@ - - - - + + + + - + - + - + - + @@ -662,25 +662,25 @@ - - - - + + + + - + - + - + - + @@ -710,25 +710,25 @@ - - - - + + + + - + - + - + - + @@ -762,25 +762,25 @@ - - - - + + + + - + - + - + - + @@ -810,25 +810,25 @@ - - - - + + + + - + - + - + - + @@ -858,25 +858,25 @@ - - - - + + + + - + - + - + - + @@ -1475,25 +1475,25 @@ - - - - + + + + - + - + - + - + @@ -1523,25 +1523,25 @@ - - - - + + + + - + - + - + - + @@ -1571,25 +1571,25 @@ - - - - + + + + - + - + - + - + @@ -1623,25 +1623,25 @@ - - - - + + + + - + - + - + - + @@ -1671,25 +1671,25 @@ - - - - + + + + - + - + - + - + @@ -1719,25 +1719,25 @@ - - - - + + + + - + - + - + - + @@ -2338,25 +2338,25 @@ - - - - + + + + - + - + - + - + @@ -2386,25 +2386,25 @@ - - - - + + + + - + - + - + - + @@ -2434,25 +2434,25 @@ - - - - + + + + - + - + - + - + @@ -2486,25 +2486,25 @@ - - - - + + + + - + - + - + - + @@ -2534,25 +2534,25 @@ - - - - + + + + - + - + - + - + @@ -2582,25 +2582,25 @@ - - - - + + + + - + - + - + - + @@ -3199,25 +3199,25 @@ - - - - + + + + - + - + - + - + @@ -3247,25 +3247,25 @@ - - - - + + + + - + - + - + - + @@ -3295,25 +3295,25 @@ - - - - + + + + - + - + - + - + @@ -3347,25 +3347,25 @@ - - - - + + + + - + - + - + - + @@ -3395,25 +3395,25 @@ - - - - + + + + - + - + - + - + @@ -3443,25 +3443,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_offset_window_with_date_part__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_offset_window_with_date_part__plan0.xml index 81d5db4a69..a311fb6801 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_offset_window_with_date_part__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_offset_window_with_date_part__plan0.xml @@ -568,25 +568,25 @@ - - - - + + + + - + - + - + - + @@ -616,25 +616,25 @@ - - - - + + + + - + - + - + - + @@ -664,25 +664,25 @@ - - - - + + + + - + - + - + - + @@ -716,25 +716,25 @@ - - - - + + + + - + - + - + - + @@ -764,25 +764,25 @@ - - - - + + + + - + - + - + - + @@ -812,25 +812,25 @@ - - - - + + + + - + - + - + - + @@ -1831,25 +1831,25 @@ - - - - + + + + - + - + - + - + @@ -1879,25 +1879,25 @@ - - - - + + + + - + - + - + - + @@ -1927,25 +1927,25 @@ - - - - + + + + - + - + - + - + @@ -1979,25 +1979,25 @@ - - - - + + + + - + - + - + - + @@ -2027,25 +2027,25 @@ - - - - + + + + - + - + - + - + @@ -2075,25 +2075,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_order_by_node__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_order_by_node__plan0.xml index 0069ee8ee7..d496a167df 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_order_by_node__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_order_by_node__plan0.xml @@ -148,25 +148,25 @@ - - - - + + + + - + - + - + - + @@ -196,25 +196,25 @@ - - - - + + + + - + - + - + - + @@ -244,25 +244,25 @@ - - - - + + + + - + - + - + - + @@ -296,25 +296,25 @@ - - - - + + + + - + - + - + - + @@ -344,25 +344,25 @@ - - - - + + + + - + - + - + - + @@ -392,25 +392,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_partitioned_join__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_partitioned_join__plan0.xml index 6fbc2644c7..1a237cabce 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_partitioned_join__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_partitioned_join__plan0.xml @@ -370,25 +370,25 @@ - - - - + + + + - + - + - + - + @@ -418,25 +418,25 @@ - - - - + + + + - + - + - + - + @@ -470,25 +470,25 @@ - - - - + + + + - + - + - + - + @@ -518,25 +518,25 @@ - - - - + + + + - + - + - + - + @@ -614,25 +614,25 @@ - - - - + + + + - + - + - + - + @@ -662,25 +662,25 @@ - - - - + + + + - + - + - + - + @@ -710,25 +710,25 @@ - - - - + + + + - + - + - + - + @@ -762,25 +762,25 @@ - - - - + + + + - + - + - + - + @@ -810,25 +810,25 @@ - - - - + + + + - + - + - + - + @@ -858,25 +858,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node__plan0.xml index f6a1229769..35e1d0ad5c 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node__plan0.xml @@ -149,25 +149,25 @@ - - - - - + + + + + - + - + - + @@ -201,25 +201,25 @@ - - - - + + + + - + - + - + - + @@ -293,25 +293,25 @@ - - - - - + + + + + - + - + - + @@ -345,25 +345,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node_with_grouping__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node_with_grouping__plan0.xml index f8ed520f2f..2c80a5c3c4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node_with_grouping__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node_with_grouping__plan0.xml @@ -149,25 +149,25 @@ - - - - - + + + + + - + - + - + @@ -201,25 +201,25 @@ - - - - + + + + - + - + - + - + @@ -301,25 +301,25 @@ - - - - - + + + + + - + - + - + @@ -353,25 +353,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node_with_queried_group_by__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node_with_queried_group_by__plan0.xml index ed70382110..50bcc0d24f 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node_with_queried_group_by__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node_with_queried_group_by__plan0.xml @@ -149,25 +149,25 @@ - - - - - + + + + + - + - + - + @@ -201,25 +201,25 @@ - - - - + + + + - + - + - + - + @@ -301,25 +301,25 @@ - - - - - + + + + + - + - + - + @@ -353,25 +353,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_simple_query_with_date_part__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_simple_query_with_date_part__plan0.xml index 49d52f7aae..89570a3daf 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_simple_query_with_date_part__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_simple_query_with_date_part__plan0.xml @@ -532,25 +532,25 @@ - - - - + + + + - + - + - + - + @@ -580,25 +580,25 @@ - - - - + + + + - + - + - + - + @@ -628,25 +628,25 @@ - - - - + + + + - + - + - + - + @@ -680,25 +680,25 @@ - - - - + + + + - + - + - + - + @@ -728,25 +728,25 @@ - - - - + + + + - + - + - + - + @@ -776,25 +776,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_simple_query_with_multiple_date_parts__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_simple_query_with_multiple_date_parts__plan0.xml index f987f53071..671a388e9e 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_simple_query_with_multiple_date_parts__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_simple_query_with_multiple_date_parts__plan0.xml @@ -635,25 +635,25 @@ - - - - + + + + - + - + - + - + @@ -683,25 +683,25 @@ - - - - + + + + - + - + - + - + @@ -731,25 +731,25 @@ - - - - + + + + - + - + - + - + @@ -783,25 +783,25 @@ - - - - + + + + - + - + - + - + @@ -831,25 +831,25 @@ - - - - + + + + - + - + - + - + @@ -879,25 +879,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_single_join_node__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_single_join_node__plan0.xml index d6e800bd30..4cc75ecba4 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_single_join_node__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_single_join_node__plan0.xml @@ -96,25 +96,25 @@ - - - - + + + + - + - + - + - + @@ -144,25 +144,25 @@ - - - - + + + + - + - + - + - + @@ -192,25 +192,25 @@ - - - - + + + + - + - + - + - + @@ -244,25 +244,25 @@ - - - - + + + + - + - + - + - + @@ -292,25 +292,25 @@ - - - - + + + + - + - + - + - + @@ -340,25 +340,25 @@ - - - - + + + + - + - + - + - + @@ -451,25 +451,25 @@ - - - - + + + + - + - + - + - + @@ -499,25 +499,25 @@ - - - - + + + + - + - + - + - + @@ -559,25 +559,25 @@ - - - - + + + + - + - + - + - + @@ -607,25 +607,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_source_node__plan0.xml b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_source_node__plan0.xml index 75df770af7..78b9e9a0c3 100644 --- a/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_source_node__plan0.xml +++ b/metricflow/test/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_source_node__plan0.xml @@ -62,25 +62,25 @@ - - - - + + + + - + - + - + - + @@ -110,25 +110,25 @@ - - - - + + + + - + - + - + - + @@ -158,25 +158,25 @@ - - - - + + + + - + - + - + - + @@ -210,25 +210,25 @@ - - - - + + + + - + - + - + - + @@ -258,25 +258,25 @@ - - - - + + + + - + - + - + - + @@ -306,25 +306,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql index ab0edb4ad2..c994abffd4 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql @@ -111,7 +111,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -123,7 +123,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -135,7 +135,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -148,7 +148,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -160,7 +160,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql index 2b917da7a9..b901605870 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'paid_at' SELECT - ds AS ds__day + DATE_TRUNC(ds, day) AS ds__day , DATE_TRUNC(ds, isoweek) AS ds__week , DATE_TRUNC(ds, month) AS ds__month , DATE_TRUNC(ds, quarter) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dayofweek FROM ds) AS ds__extract_dow , EXTRACT(dayofyear FROM ds) AS ds__extract_doy - , ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(ds_partitioned, quarter) AS ds_partitioned__quarter @@ -25,7 +25,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM ds_partitioned) AS ds_partitioned__extract_doy - , paid_at AS paid_at__day + , DATE_TRUNC(paid_at, day) AS paid_at__day , DATE_TRUNC(paid_at, isoweek) AS paid_at__week , DATE_TRUNC(paid_at, month) AS paid_at__month , DATE_TRUNC(paid_at, quarter) AS paid_at__quarter @@ -37,7 +37,7 @@ SELECT , EXTRACT(day FROM paid_at) AS paid_at__extract_day , EXTRACT(dayofweek FROM paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM paid_at) AS paid_at__extract_doy - , ds AS booking__ds__day + , DATE_TRUNC(ds, day) AS booking__ds__day , DATE_TRUNC(ds, isoweek) AS booking__ds__week , DATE_TRUNC(ds, month) AS booking__ds__month , DATE_TRUNC(ds, quarter) AS booking__ds__quarter @@ -49,7 +49,7 @@ SELECT , EXTRACT(day FROM ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM ds) AS booking__ds__extract_doy - , ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -61,7 +61,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM ds_partitioned) AS booking__ds_partitioned__extract_doy - , paid_at AS booking__paid_at__day + , DATE_TRUNC(paid_at, day) AS booking__paid_at__day , DATE_TRUNC(paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(paid_at, month) AS booking__paid_at__month , DATE_TRUNC(paid_at, quarter) AS booking__paid_at__quarter @@ -73,7 +73,7 @@ SELECT , EXTRACT(day FROM paid_at) AS booking__paid_at__extract_day , EXTRACT(dayofweek FROM paid_at) AS booking__paid_at__extract_dow , EXTRACT(dayofyear FROM paid_at) AS booking__paid_at__extract_doy - , paid_at AS metric_time__day + , DATE_TRUNC(paid_at, day) AS metric_time__day , DATE_TRUNC(paid_at, isoweek) AS metric_time__week , DATE_TRUNC(paid_at, month) AS metric_time__month , DATE_TRUNC(paid_at, quarter) AS metric_time__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql index 58b676e2ff..734df47799 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql @@ -123,7 +123,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -135,7 +135,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -147,7 +147,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -160,7 +160,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -184,7 +184,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql index 6290ee58d6..b288876db9 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS ds__day + DATE_TRUNC(ds, day) AS ds__day , DATE_TRUNC(ds, isoweek) AS ds__week , DATE_TRUNC(ds, month) AS ds__month , DATE_TRUNC(ds, quarter) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dayofweek FROM ds) AS ds__extract_dow , EXTRACT(dayofyear FROM ds) AS ds__extract_doy - , ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(ds_partitioned, quarter) AS ds_partitioned__quarter @@ -25,7 +25,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM ds_partitioned) AS ds_partitioned__extract_doy - , paid_at AS paid_at__day + , DATE_TRUNC(paid_at, day) AS paid_at__day , DATE_TRUNC(paid_at, isoweek) AS paid_at__week , DATE_TRUNC(paid_at, month) AS paid_at__month , DATE_TRUNC(paid_at, quarter) AS paid_at__quarter @@ -37,7 +37,7 @@ SELECT , EXTRACT(day FROM paid_at) AS paid_at__extract_day , EXTRACT(dayofweek FROM paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM paid_at) AS paid_at__extract_doy - , ds AS booking__ds__day + , DATE_TRUNC(ds, day) AS booking__ds__day , DATE_TRUNC(ds, isoweek) AS booking__ds__week , DATE_TRUNC(ds, month) AS booking__ds__month , DATE_TRUNC(ds, quarter) AS booking__ds__quarter @@ -49,7 +49,7 @@ SELECT , EXTRACT(day FROM ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM ds) AS booking__ds__extract_doy - , ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -61,7 +61,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM ds_partitioned) AS booking__ds_partitioned__extract_doy - , paid_at AS booking__paid_at__day + , DATE_TRUNC(paid_at, day) AS booking__paid_at__day , DATE_TRUNC(paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(paid_at, month) AS booking__paid_at__month , DATE_TRUNC(paid_at, quarter) AS booking__paid_at__quarter @@ -73,7 +73,7 @@ SELECT , EXTRACT(day FROM paid_at) AS booking__paid_at__extract_day , EXTRACT(dayofweek FROM paid_at) AS booking__paid_at__extract_dow , EXTRACT(dayofyear FROM paid_at) AS booking__paid_at__extract_doy - , ds AS metric_time__day + , DATE_TRUNC(ds, day) AS metric_time__day , DATE_TRUNC(ds, isoweek) AS metric_time__week , DATE_TRUNC(ds, month) AS metric_time__month , DATE_TRUNC(ds, quarter) AS metric_time__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_simple_query_with_metric_time_dimension__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_simple_query_with_metric_time_dimension__plan0.sql index 24e3bb6ff9..3b79e3dde0 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_simple_query_with_metric_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_simple_query_with_metric_time_dimension__plan0.sql @@ -145,7 +145,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -157,7 +157,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -182,7 +182,7 @@ FROM ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter @@ -362,7 +362,7 @@ FULL OUTER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS ds__quarter @@ -374,7 +374,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS ds_partitioned__quarter @@ -386,7 +386,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS paid_at__quarter @@ -399,7 +399,7 @@ FULL OUTER JOIN ( , EXTRACT(dayofweek FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC(bookings_source_src_10001.ds, day) AS booking__ds__day , DATE_TRUNC(bookings_source_src_10001.ds, isoweek) AS booking__ds__week , DATE_TRUNC(bookings_source_src_10001.ds, month) AS booking__ds__month , DATE_TRUNC(bookings_source_src_10001.ds, quarter) AS booking__ds__quarter @@ -411,7 +411,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, day) AS booking__ds_partitioned__day , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, isoweek) AS booking__ds_partitioned__week , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, month) AS booking__ds_partitioned__month , DATE_TRUNC(bookings_source_src_10001.ds_partitioned, quarter) AS booking__ds_partitioned__quarter @@ -423,7 +423,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dayofweek FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(dayofyear FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC(bookings_source_src_10001.paid_at, day) AS booking__paid_at__day , DATE_TRUNC(bookings_source_src_10001.paid_at, isoweek) AS booking__paid_at__week , DATE_TRUNC(bookings_source_src_10001.paid_at, month) AS booking__paid_at__month , DATE_TRUNC(bookings_source_src_10001.paid_at, quarter) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_simple_query_with_metric_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_simple_query_with_metric_time_dimension__plan0_optimized.sql index 81150c6b90..aa96d4e0fa 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_simple_query_with_metric_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/BigQuery/test_simple_query_with_metric_time_dimension__plan0_optimized.sql @@ -15,7 +15,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_12 @@ -30,7 +30,7 @@ FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - paid_at AS metric_time__day + DATE_TRUNC(paid_at, day) AS metric_time__day , SUM(booking_value) AS booking_payments FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql index e9ab8e5153..4d7f9ffb29 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql @@ -111,7 +111,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -123,7 +123,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -135,7 +135,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -148,7 +148,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -160,7 +160,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql index 00e036ec03..95e26846a1 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'paid_at' SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy - , ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS ds_partitioned__quarter @@ -25,7 +25,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS ds_partitioned__extract_doy - , paid_at AS paid_at__day + , DATE_TRUNC('day', paid_at) AS paid_at__day , DATE_TRUNC('week', paid_at) AS paid_at__week , DATE_TRUNC('month', paid_at) AS paid_at__month , DATE_TRUNC('quarter', paid_at) AS paid_at__quarter @@ -37,7 +37,7 @@ SELECT , EXTRACT(day FROM paid_at) AS paid_at__extract_day , EXTRACT(dow FROM paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS paid_at__extract_doy - , ds AS booking__ds__day + , DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('week', ds) AS booking__ds__week , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('quarter', ds) AS booking__ds__quarter @@ -49,7 +49,7 @@ SELECT , EXTRACT(day FROM ds) AS booking__ds__extract_day , EXTRACT(dow FROM ds) AS booking__ds__extract_dow , EXTRACT(doy FROM ds) AS booking__ds__extract_doy - , ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS booking__ds_partitioned__quarter @@ -61,7 +61,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS booking__ds_partitioned__extract_doy - , paid_at AS booking__paid_at__day + , DATE_TRUNC('day', paid_at) AS booking__paid_at__day , DATE_TRUNC('week', paid_at) AS booking__paid_at__week , DATE_TRUNC('month', paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter @@ -73,7 +73,7 @@ SELECT , EXTRACT(day FROM paid_at) AS booking__paid_at__extract_day , EXTRACT(dow FROM paid_at) AS booking__paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS booking__paid_at__extract_doy - , paid_at AS metric_time__day + , DATE_TRUNC('day', paid_at) AS metric_time__day , DATE_TRUNC('week', paid_at) AS metric_time__week , DATE_TRUNC('month', paid_at) AS metric_time__month , DATE_TRUNC('quarter', paid_at) AS metric_time__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql index e2cc747ae2..ecdb3732ed 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql @@ -123,7 +123,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -135,7 +135,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -147,7 +147,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -160,7 +160,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -184,7 +184,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql index c6d742fae0..d16a04f807 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy - , ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS ds_partitioned__quarter @@ -25,7 +25,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS ds_partitioned__extract_doy - , paid_at AS paid_at__day + , DATE_TRUNC('day', paid_at) AS paid_at__day , DATE_TRUNC('week', paid_at) AS paid_at__week , DATE_TRUNC('month', paid_at) AS paid_at__month , DATE_TRUNC('quarter', paid_at) AS paid_at__quarter @@ -37,7 +37,7 @@ SELECT , EXTRACT(day FROM paid_at) AS paid_at__extract_day , EXTRACT(dow FROM paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS paid_at__extract_doy - , ds AS booking__ds__day + , DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('week', ds) AS booking__ds__week , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('quarter', ds) AS booking__ds__quarter @@ -49,7 +49,7 @@ SELECT , EXTRACT(day FROM ds) AS booking__ds__extract_day , EXTRACT(dow FROM ds) AS booking__ds__extract_dow , EXTRACT(doy FROM ds) AS booking__ds__extract_doy - , ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS booking__ds_partitioned__quarter @@ -61,7 +61,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS booking__ds_partitioned__extract_doy - , paid_at AS booking__paid_at__day + , DATE_TRUNC('day', paid_at) AS booking__paid_at__day , DATE_TRUNC('week', paid_at) AS booking__paid_at__week , DATE_TRUNC('month', paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter @@ -73,7 +73,7 @@ SELECT , EXTRACT(day FROM paid_at) AS booking__paid_at__extract_day , EXTRACT(dow FROM paid_at) AS booking__paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS booking__paid_at__extract_doy - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week , DATE_TRUNC('month', ds) AS metric_time__month , DATE_TRUNC('quarter', ds) AS metric_time__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_simple_query_with_metric_time_dimension__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_simple_query_with_metric_time_dimension__plan0.sql index c88105f92d..85c2b5d83d 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_simple_query_with_metric_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_simple_query_with_metric_time_dimension__plan0.sql @@ -145,7 +145,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -157,7 +157,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -182,7 +182,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -362,7 +362,7 @@ FULL OUTER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -374,7 +374,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -386,7 +386,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -399,7 +399,7 @@ FULL OUTER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -411,7 +411,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -423,7 +423,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_simple_query_with_metric_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_simple_query_with_metric_time_dimension__plan0_optimized.sql index 0a8efb1bc9..873beed5f6 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_simple_query_with_metric_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Databricks/test_simple_query_with_metric_time_dimension__plan0_optimized.sql @@ -15,7 +15,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_12 @@ -30,11 +30,11 @@ FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - paid_at AS metric_time__day + DATE_TRUNC('day', paid_at) AS metric_time__day , SUM(booking_value) AS booking_payments FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - paid_at + DATE_TRUNC('day', paid_at) ) subq_19 ON subq_14.metric_time__day = subq_19.metric_time__day diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql index e9ab8e5153..4d7f9ffb29 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql @@ -111,7 +111,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -123,7 +123,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -135,7 +135,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -148,7 +148,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -160,7 +160,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql index 00e036ec03..95e26846a1 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'paid_at' SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy - , ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS ds_partitioned__quarter @@ -25,7 +25,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS ds_partitioned__extract_doy - , paid_at AS paid_at__day + , DATE_TRUNC('day', paid_at) AS paid_at__day , DATE_TRUNC('week', paid_at) AS paid_at__week , DATE_TRUNC('month', paid_at) AS paid_at__month , DATE_TRUNC('quarter', paid_at) AS paid_at__quarter @@ -37,7 +37,7 @@ SELECT , EXTRACT(day FROM paid_at) AS paid_at__extract_day , EXTRACT(dow FROM paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS paid_at__extract_doy - , ds AS booking__ds__day + , DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('week', ds) AS booking__ds__week , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('quarter', ds) AS booking__ds__quarter @@ -49,7 +49,7 @@ SELECT , EXTRACT(day FROM ds) AS booking__ds__extract_day , EXTRACT(dow FROM ds) AS booking__ds__extract_dow , EXTRACT(doy FROM ds) AS booking__ds__extract_doy - , ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS booking__ds_partitioned__quarter @@ -61,7 +61,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS booking__ds_partitioned__extract_doy - , paid_at AS booking__paid_at__day + , DATE_TRUNC('day', paid_at) AS booking__paid_at__day , DATE_TRUNC('week', paid_at) AS booking__paid_at__week , DATE_TRUNC('month', paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter @@ -73,7 +73,7 @@ SELECT , EXTRACT(day FROM paid_at) AS booking__paid_at__extract_day , EXTRACT(dow FROM paid_at) AS booking__paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS booking__paid_at__extract_doy - , paid_at AS metric_time__day + , DATE_TRUNC('day', paid_at) AS metric_time__day , DATE_TRUNC('week', paid_at) AS metric_time__week , DATE_TRUNC('month', paid_at) AS metric_time__month , DATE_TRUNC('quarter', paid_at) AS metric_time__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql index e2cc747ae2..ecdb3732ed 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql @@ -123,7 +123,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -135,7 +135,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -147,7 +147,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -160,7 +160,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -184,7 +184,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql index c6d742fae0..d16a04f807 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy - , ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS ds_partitioned__quarter @@ -25,7 +25,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS ds_partitioned__extract_doy - , paid_at AS paid_at__day + , DATE_TRUNC('day', paid_at) AS paid_at__day , DATE_TRUNC('week', paid_at) AS paid_at__week , DATE_TRUNC('month', paid_at) AS paid_at__month , DATE_TRUNC('quarter', paid_at) AS paid_at__quarter @@ -37,7 +37,7 @@ SELECT , EXTRACT(day FROM paid_at) AS paid_at__extract_day , EXTRACT(dow FROM paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS paid_at__extract_doy - , ds AS booking__ds__day + , DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('week', ds) AS booking__ds__week , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('quarter', ds) AS booking__ds__quarter @@ -49,7 +49,7 @@ SELECT , EXTRACT(day FROM ds) AS booking__ds__extract_day , EXTRACT(dow FROM ds) AS booking__ds__extract_dow , EXTRACT(doy FROM ds) AS booking__ds__extract_doy - , ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS booking__ds_partitioned__quarter @@ -61,7 +61,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS booking__ds_partitioned__extract_doy - , paid_at AS booking__paid_at__day + , DATE_TRUNC('day', paid_at) AS booking__paid_at__day , DATE_TRUNC('week', paid_at) AS booking__paid_at__week , DATE_TRUNC('month', paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter @@ -73,7 +73,7 @@ SELECT , EXTRACT(day FROM paid_at) AS booking__paid_at__extract_day , EXTRACT(dow FROM paid_at) AS booking__paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS booking__paid_at__extract_doy - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week , DATE_TRUNC('month', ds) AS metric_time__month , DATE_TRUNC('quarter', ds) AS metric_time__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_simple_query_with_metric_time_dimension__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_simple_query_with_metric_time_dimension__plan0.sql index c88105f92d..85c2b5d83d 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_simple_query_with_metric_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_simple_query_with_metric_time_dimension__plan0.sql @@ -145,7 +145,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -157,7 +157,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -182,7 +182,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -362,7 +362,7 @@ FULL OUTER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -374,7 +374,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -386,7 +386,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -399,7 +399,7 @@ FULL OUTER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -411,7 +411,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -423,7 +423,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_simple_query_with_metric_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_simple_query_with_metric_time_dimension__plan0_optimized.sql index 0a8efb1bc9..873beed5f6 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_simple_query_with_metric_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/DuckDB/test_simple_query_with_metric_time_dimension__plan0_optimized.sql @@ -15,7 +15,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_12 @@ -30,11 +30,11 @@ FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - paid_at AS metric_time__day + DATE_TRUNC('day', paid_at) AS metric_time__day , SUM(booking_value) AS booking_payments FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - paid_at + DATE_TRUNC('day', paid_at) ) subq_19 ON subq_14.metric_time__day = subq_19.metric_time__day diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql index e9ab8e5153..4d7f9ffb29 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql @@ -111,7 +111,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -123,7 +123,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -135,7 +135,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -148,7 +148,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -160,7 +160,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql index 00e036ec03..95e26846a1 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'paid_at' SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy - , ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS ds_partitioned__quarter @@ -25,7 +25,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS ds_partitioned__extract_doy - , paid_at AS paid_at__day + , DATE_TRUNC('day', paid_at) AS paid_at__day , DATE_TRUNC('week', paid_at) AS paid_at__week , DATE_TRUNC('month', paid_at) AS paid_at__month , DATE_TRUNC('quarter', paid_at) AS paid_at__quarter @@ -37,7 +37,7 @@ SELECT , EXTRACT(day FROM paid_at) AS paid_at__extract_day , EXTRACT(dow FROM paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS paid_at__extract_doy - , ds AS booking__ds__day + , DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('week', ds) AS booking__ds__week , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('quarter', ds) AS booking__ds__quarter @@ -49,7 +49,7 @@ SELECT , EXTRACT(day FROM ds) AS booking__ds__extract_day , EXTRACT(dow FROM ds) AS booking__ds__extract_dow , EXTRACT(doy FROM ds) AS booking__ds__extract_doy - , ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS booking__ds_partitioned__quarter @@ -61,7 +61,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS booking__ds_partitioned__extract_doy - , paid_at AS booking__paid_at__day + , DATE_TRUNC('day', paid_at) AS booking__paid_at__day , DATE_TRUNC('week', paid_at) AS booking__paid_at__week , DATE_TRUNC('month', paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter @@ -73,7 +73,7 @@ SELECT , EXTRACT(day FROM paid_at) AS booking__paid_at__extract_day , EXTRACT(dow FROM paid_at) AS booking__paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS booking__paid_at__extract_doy - , paid_at AS metric_time__day + , DATE_TRUNC('day', paid_at) AS metric_time__day , DATE_TRUNC('week', paid_at) AS metric_time__week , DATE_TRUNC('month', paid_at) AS metric_time__month , DATE_TRUNC('quarter', paid_at) AS metric_time__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql index e2cc747ae2..ecdb3732ed 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql @@ -123,7 +123,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -135,7 +135,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -147,7 +147,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -160,7 +160,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -184,7 +184,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql index c6d742fae0..d16a04f807 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy - , ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS ds_partitioned__quarter @@ -25,7 +25,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS ds_partitioned__extract_doy - , paid_at AS paid_at__day + , DATE_TRUNC('day', paid_at) AS paid_at__day , DATE_TRUNC('week', paid_at) AS paid_at__week , DATE_TRUNC('month', paid_at) AS paid_at__month , DATE_TRUNC('quarter', paid_at) AS paid_at__quarter @@ -37,7 +37,7 @@ SELECT , EXTRACT(day FROM paid_at) AS paid_at__extract_day , EXTRACT(dow FROM paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS paid_at__extract_doy - , ds AS booking__ds__day + , DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('week', ds) AS booking__ds__week , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('quarter', ds) AS booking__ds__quarter @@ -49,7 +49,7 @@ SELECT , EXTRACT(day FROM ds) AS booking__ds__extract_day , EXTRACT(dow FROM ds) AS booking__ds__extract_dow , EXTRACT(doy FROM ds) AS booking__ds__extract_doy - , ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS booking__ds_partitioned__quarter @@ -61,7 +61,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS booking__ds_partitioned__extract_doy - , paid_at AS booking__paid_at__day + , DATE_TRUNC('day', paid_at) AS booking__paid_at__day , DATE_TRUNC('week', paid_at) AS booking__paid_at__week , DATE_TRUNC('month', paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter @@ -73,7 +73,7 @@ SELECT , EXTRACT(day FROM paid_at) AS booking__paid_at__extract_day , EXTRACT(dow FROM paid_at) AS booking__paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS booking__paid_at__extract_doy - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week , DATE_TRUNC('month', ds) AS metric_time__month , DATE_TRUNC('quarter', ds) AS metric_time__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_simple_query_with_metric_time_dimension__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_simple_query_with_metric_time_dimension__plan0.sql index c88105f92d..85c2b5d83d 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_simple_query_with_metric_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_simple_query_with_metric_time_dimension__plan0.sql @@ -145,7 +145,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -157,7 +157,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -182,7 +182,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -362,7 +362,7 @@ FULL OUTER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -374,7 +374,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -386,7 +386,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -399,7 +399,7 @@ FULL OUTER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -411,7 +411,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -423,7 +423,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_simple_query_with_metric_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_simple_query_with_metric_time_dimension__plan0_optimized.sql index 0a8efb1bc9..873beed5f6 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_simple_query_with_metric_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Postgres/test_simple_query_with_metric_time_dimension__plan0_optimized.sql @@ -15,7 +15,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_12 @@ -30,11 +30,11 @@ FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - paid_at AS metric_time__day + DATE_TRUNC('day', paid_at) AS metric_time__day , SUM(booking_value) AS booking_payments FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - paid_at + DATE_TRUNC('day', paid_at) ) subq_19 ON subq_14.metric_time__day = subq_19.metric_time__day diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql index e9ab8e5153..4d7f9ffb29 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql @@ -111,7 +111,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -123,7 +123,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -135,7 +135,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -148,7 +148,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -160,7 +160,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql index 00e036ec03..95e26846a1 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'paid_at' SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy - , ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS ds_partitioned__quarter @@ -25,7 +25,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS ds_partitioned__extract_doy - , paid_at AS paid_at__day + , DATE_TRUNC('day', paid_at) AS paid_at__day , DATE_TRUNC('week', paid_at) AS paid_at__week , DATE_TRUNC('month', paid_at) AS paid_at__month , DATE_TRUNC('quarter', paid_at) AS paid_at__quarter @@ -37,7 +37,7 @@ SELECT , EXTRACT(day FROM paid_at) AS paid_at__extract_day , EXTRACT(dow FROM paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS paid_at__extract_doy - , ds AS booking__ds__day + , DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('week', ds) AS booking__ds__week , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('quarter', ds) AS booking__ds__quarter @@ -49,7 +49,7 @@ SELECT , EXTRACT(day FROM ds) AS booking__ds__extract_day , EXTRACT(dow FROM ds) AS booking__ds__extract_dow , EXTRACT(doy FROM ds) AS booking__ds__extract_doy - , ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS booking__ds_partitioned__quarter @@ -61,7 +61,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS booking__ds_partitioned__extract_doy - , paid_at AS booking__paid_at__day + , DATE_TRUNC('day', paid_at) AS booking__paid_at__day , DATE_TRUNC('week', paid_at) AS booking__paid_at__week , DATE_TRUNC('month', paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter @@ -73,7 +73,7 @@ SELECT , EXTRACT(day FROM paid_at) AS booking__paid_at__extract_day , EXTRACT(dow FROM paid_at) AS booking__paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS booking__paid_at__extract_doy - , paid_at AS metric_time__day + , DATE_TRUNC('day', paid_at) AS metric_time__day , DATE_TRUNC('week', paid_at) AS metric_time__week , DATE_TRUNC('month', paid_at) AS metric_time__month , DATE_TRUNC('quarter', paid_at) AS metric_time__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql index e2cc747ae2..ecdb3732ed 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql @@ -123,7 +123,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -135,7 +135,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -147,7 +147,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -160,7 +160,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -184,7 +184,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql index c6d742fae0..d16a04f807 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy - , ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS ds_partitioned__quarter @@ -25,7 +25,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS ds_partitioned__extract_doy - , paid_at AS paid_at__day + , DATE_TRUNC('day', paid_at) AS paid_at__day , DATE_TRUNC('week', paid_at) AS paid_at__week , DATE_TRUNC('month', paid_at) AS paid_at__month , DATE_TRUNC('quarter', paid_at) AS paid_at__quarter @@ -37,7 +37,7 @@ SELECT , EXTRACT(day FROM paid_at) AS paid_at__extract_day , EXTRACT(dow FROM paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS paid_at__extract_doy - , ds AS booking__ds__day + , DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('week', ds) AS booking__ds__week , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('quarter', ds) AS booking__ds__quarter @@ -49,7 +49,7 @@ SELECT , EXTRACT(day FROM ds) AS booking__ds__extract_day , EXTRACT(dow FROM ds) AS booking__ds__extract_dow , EXTRACT(doy FROM ds) AS booking__ds__extract_doy - , ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS booking__ds_partitioned__quarter @@ -61,7 +61,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS booking__ds_partitioned__extract_doy - , paid_at AS booking__paid_at__day + , DATE_TRUNC('day', paid_at) AS booking__paid_at__day , DATE_TRUNC('week', paid_at) AS booking__paid_at__week , DATE_TRUNC('month', paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter @@ -73,7 +73,7 @@ SELECT , EXTRACT(day FROM paid_at) AS booking__paid_at__extract_day , EXTRACT(dow FROM paid_at) AS booking__paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS booking__paid_at__extract_doy - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week , DATE_TRUNC('month', ds) AS metric_time__month , DATE_TRUNC('quarter', ds) AS metric_time__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_simple_query_with_metric_time_dimension__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_simple_query_with_metric_time_dimension__plan0.sql index c88105f92d..85c2b5d83d 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_simple_query_with_metric_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_simple_query_with_metric_time_dimension__plan0.sql @@ -145,7 +145,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -157,7 +157,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -182,7 +182,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -362,7 +362,7 @@ FULL OUTER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -374,7 +374,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -386,7 +386,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -399,7 +399,7 @@ FULL OUTER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -411,7 +411,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -423,7 +423,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_simple_query_with_metric_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_simple_query_with_metric_time_dimension__plan0_optimized.sql index 0a8efb1bc9..873beed5f6 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_simple_query_with_metric_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Redshift/test_simple_query_with_metric_time_dimension__plan0_optimized.sql @@ -15,7 +15,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_12 @@ -30,11 +30,11 @@ FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - paid_at AS metric_time__day + DATE_TRUNC('day', paid_at) AS metric_time__day , SUM(booking_value) AS booking_payments FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - paid_at + DATE_TRUNC('day', paid_at) ) subq_19 ON subq_14.metric_time__day = subq_19.metric_time__day diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql index e9ab8e5153..4d7f9ffb29 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.sql @@ -111,7 +111,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -123,7 +123,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -135,7 +135,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -148,7 +148,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -160,7 +160,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql index 00e036ec03..95e26846a1 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_non_primary_time__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'paid_at' SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy - , ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS ds_partitioned__quarter @@ -25,7 +25,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS ds_partitioned__extract_doy - , paid_at AS paid_at__day + , DATE_TRUNC('day', paid_at) AS paid_at__day , DATE_TRUNC('week', paid_at) AS paid_at__week , DATE_TRUNC('month', paid_at) AS paid_at__month , DATE_TRUNC('quarter', paid_at) AS paid_at__quarter @@ -37,7 +37,7 @@ SELECT , EXTRACT(day FROM paid_at) AS paid_at__extract_day , EXTRACT(dow FROM paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS paid_at__extract_doy - , ds AS booking__ds__day + , DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('week', ds) AS booking__ds__week , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('quarter', ds) AS booking__ds__quarter @@ -49,7 +49,7 @@ SELECT , EXTRACT(day FROM ds) AS booking__ds__extract_day , EXTRACT(dow FROM ds) AS booking__ds__extract_dow , EXTRACT(doy FROM ds) AS booking__ds__extract_doy - , ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS booking__ds_partitioned__quarter @@ -61,7 +61,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS booking__ds_partitioned__extract_doy - , paid_at AS booking__paid_at__day + , DATE_TRUNC('day', paid_at) AS booking__paid_at__day , DATE_TRUNC('week', paid_at) AS booking__paid_at__week , DATE_TRUNC('month', paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter @@ -73,7 +73,7 @@ SELECT , EXTRACT(day FROM paid_at) AS booking__paid_at__extract_day , EXTRACT(dow FROM paid_at) AS booking__paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS booking__paid_at__extract_doy - , paid_at AS metric_time__day + , DATE_TRUNC('day', paid_at) AS metric_time__day , DATE_TRUNC('week', paid_at) AS metric_time__week , DATE_TRUNC('month', paid_at) AS metric_time__month , DATE_TRUNC('quarter', paid_at) AS metric_time__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql index e2cc747ae2..ecdb3732ed 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_primary_time__plan0.sql @@ -123,7 +123,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -135,7 +135,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -147,7 +147,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -160,7 +160,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -172,7 +172,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -184,7 +184,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql index c6d742fae0..d16a04f807 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_metric_time_dimension_transform_node_using_primary_time__plan0_optimized.sql @@ -1,7 +1,7 @@ -- Read Elements From Semantic Model 'bookings_source' -- Metric Time Dimension 'ds' SELECT - ds AS ds__day + DATE_TRUNC('day', ds) AS ds__day , DATE_TRUNC('week', ds) AS ds__week , DATE_TRUNC('month', ds) AS ds__month , DATE_TRUNC('quarter', ds) AS ds__quarter @@ -13,7 +13,7 @@ SELECT , EXTRACT(day FROM ds) AS ds__extract_day , EXTRACT(dow FROM ds) AS ds__extract_dow , EXTRACT(doy FROM ds) AS ds__extract_doy - , ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS ds_partitioned__quarter @@ -25,7 +25,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS ds_partitioned__extract_doy - , paid_at AS paid_at__day + , DATE_TRUNC('day', paid_at) AS paid_at__day , DATE_TRUNC('week', paid_at) AS paid_at__week , DATE_TRUNC('month', paid_at) AS paid_at__month , DATE_TRUNC('quarter', paid_at) AS paid_at__quarter @@ -37,7 +37,7 @@ SELECT , EXTRACT(day FROM paid_at) AS paid_at__extract_day , EXTRACT(dow FROM paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS paid_at__extract_doy - , ds AS booking__ds__day + , DATE_TRUNC('day', ds) AS booking__ds__day , DATE_TRUNC('week', ds) AS booking__ds__week , DATE_TRUNC('month', ds) AS booking__ds__month , DATE_TRUNC('quarter', ds) AS booking__ds__quarter @@ -49,7 +49,7 @@ SELECT , EXTRACT(day FROM ds) AS booking__ds__extract_day , EXTRACT(dow FROM ds) AS booking__ds__extract_dow , EXTRACT(doy FROM ds) AS booking__ds__extract_doy - , ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', ds_partitioned) AS booking__ds_partitioned__quarter @@ -61,7 +61,7 @@ SELECT , EXTRACT(day FROM ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM ds_partitioned) AS booking__ds_partitioned__extract_doy - , paid_at AS booking__paid_at__day + , DATE_TRUNC('day', paid_at) AS booking__paid_at__day , DATE_TRUNC('week', paid_at) AS booking__paid_at__week , DATE_TRUNC('month', paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', paid_at) AS booking__paid_at__quarter @@ -73,7 +73,7 @@ SELECT , EXTRACT(day FROM paid_at) AS booking__paid_at__extract_day , EXTRACT(dow FROM paid_at) AS booking__paid_at__extract_dow , EXTRACT(doy FROM paid_at) AS booking__paid_at__extract_doy - , ds AS metric_time__day + , DATE_TRUNC('day', ds) AS metric_time__day , DATE_TRUNC('week', ds) AS metric_time__week , DATE_TRUNC('month', ds) AS metric_time__month , DATE_TRUNC('quarter', ds) AS metric_time__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_simple_query_with_metric_time_dimension__plan0.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_simple_query_with_metric_time_dimension__plan0.sql index c88105f92d..85c2b5d83d 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_simple_query_with_metric_time_dimension__plan0.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_simple_query_with_metric_time_dimension__plan0.sql @@ -145,7 +145,7 @@ FROM ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -157,7 +157,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -169,7 +169,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -182,7 +182,7 @@ FROM ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -194,7 +194,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -206,7 +206,7 @@ FROM ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter @@ -362,7 +362,7 @@ FULL OUTER JOIN ( , bookings_source_src_10001.booking_value AS approximate_continuous_booking_value_p99 , bookings_source_src_10001.booking_value AS approximate_discrete_booking_value_p99 , bookings_source_src_10001.is_instant - , bookings_source_src_10001.ds AS ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS ds__quarter @@ -374,7 +374,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS ds_partitioned__quarter @@ -386,7 +386,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS paid_at__quarter @@ -399,7 +399,7 @@ FULL OUTER JOIN ( , EXTRACT(dow FROM bookings_source_src_10001.paid_at) AS paid_at__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.paid_at) AS paid_at__extract_doy , bookings_source_src_10001.is_instant AS booking__is_instant - , bookings_source_src_10001.ds AS booking__ds__day + , DATE_TRUNC('day', bookings_source_src_10001.ds) AS booking__ds__day , DATE_TRUNC('week', bookings_source_src_10001.ds) AS booking__ds__week , DATE_TRUNC('month', bookings_source_src_10001.ds) AS booking__ds__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds) AS booking__ds__quarter @@ -411,7 +411,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds) AS booking__ds__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds) AS booking__ds__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds) AS booking__ds__extract_doy - , bookings_source_src_10001.ds_partitioned AS booking__ds_partitioned__day + , DATE_TRUNC('day', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__day , DATE_TRUNC('week', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__week , DATE_TRUNC('month', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__month , DATE_TRUNC('quarter', bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__quarter @@ -423,7 +423,7 @@ FULL OUTER JOIN ( , EXTRACT(day FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_day , EXTRACT(dow FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_dow , EXTRACT(doy FROM bookings_source_src_10001.ds_partitioned) AS booking__ds_partitioned__extract_doy - , bookings_source_src_10001.paid_at AS booking__paid_at__day + , DATE_TRUNC('day', bookings_source_src_10001.paid_at) AS booking__paid_at__day , DATE_TRUNC('week', bookings_source_src_10001.paid_at) AS booking__paid_at__week , DATE_TRUNC('month', bookings_source_src_10001.paid_at) AS booking__paid_at__month , DATE_TRUNC('quarter', bookings_source_src_10001.paid_at) AS booking__paid_at__quarter diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_simple_query_with_metric_time_dimension__plan0_optimized.sql b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_simple_query_with_metric_time_dimension__plan0_optimized.sql index 0a8efb1bc9..873beed5f6 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_simple_query_with_metric_time_dimension__plan0_optimized.sql +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/Snowflake/test_simple_query_with_metric_time_dimension__plan0_optimized.sql @@ -15,7 +15,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_10001 ) subq_12 @@ -30,11 +30,11 @@ FULL OUTER JOIN ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - paid_at AS metric_time__day + DATE_TRUNC('day', paid_at) AS metric_time__day , SUM(booking_value) AS booking_payments FROM ***************************.fct_bookings bookings_source_src_10001 GROUP BY - paid_at + DATE_TRUNC('day', paid_at) ) subq_19 ON subq_14.metric_time__day = subq_19.metric_time__day diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.xml b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.xml index 84429ca4f1..758691a53a 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.xml +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.xml @@ -439,25 +439,25 @@ - - - - + + + + - + - + - + - + @@ -487,25 +487,25 @@ - - - - + + + + - + - + - + - + @@ -535,25 +535,25 @@ - - - - + + + + - + - + - + - + @@ -587,25 +587,25 @@ - - - - + + + + - + - + - + - + @@ -635,25 +635,25 @@ - - - - + + + + - + - + - + - + @@ -683,25 +683,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_metric_time_dimension_transform_node_using_primary_time__plan0.xml b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_metric_time_dimension_transform_node_using_primary_time__plan0.xml index f20c045afe..000af40153 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_metric_time_dimension_transform_node_using_primary_time__plan0.xml +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_metric_time_dimension_transform_node_using_primary_time__plan0.xml @@ -487,25 +487,25 @@ - - - - + + + + - + - + - + - + @@ -535,25 +535,25 @@ - - - - + + + + - + - + - + - + @@ -583,25 +583,25 @@ - - - - + + + + - + - + - + - + @@ -635,25 +635,25 @@ - - - - + + + + - + - + - + - + @@ -683,25 +683,25 @@ - - - - + + + + - + - + - + - + @@ -731,25 +731,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_simple_query_with_metric_time_dimension__plan0.xml b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_simple_query_with_metric_time_dimension__plan0.xml index 66d7813741..4558bb3498 100644 --- a/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_simple_query_with_metric_time_dimension__plan0.xml +++ b/metricflow/test/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_simple_query_with_metric_time_dimension__plan0.xml @@ -559,25 +559,25 @@ - - - - + + + + - + - + - + - + @@ -607,25 +607,25 @@ - - - - + + + + - + - + - + - + @@ -655,25 +655,25 @@ - - - - + + + + - + - + - + - + @@ -707,25 +707,25 @@ - - - - + + + + - + - + - + - + @@ -755,25 +755,25 @@ - - - - + + + + - + - + - + - + @@ -803,25 +803,25 @@ - - - - + + + + - + - + - + - + @@ -1372,25 +1372,25 @@ - - - - + + + + - + - + - + - + @@ -1420,25 +1420,25 @@ - - - - + + + + - + - + - + - + @@ -1468,25 +1468,25 @@ - - - - + + + + - + - + - + - + @@ -1520,25 +1520,25 @@ - - - - + + + + - + - + - + - + @@ -1568,25 +1568,25 @@ - - - - + + + + - + - + - + - + @@ -1616,25 +1616,25 @@ - - - - + + + + - + - + - + - + diff --git a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/BigQuery/test_render_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/BigQuery/test_render_query__query0.sql index c7949f8a59..b448f86cef 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/BigQuery/test_render_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/BigQuery/test_render_query__query0.sql @@ -9,7 +9,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/BigQuery/test_render_write_to_table_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/BigQuery/test_render_write_to_table_query__query0.sql index 701465ead6..61c9766c76 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/BigQuery/test_render_write_to_table_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/BigQuery/test_render_write_to_table_query__query0.sql @@ -10,7 +10,7 @@ CREATE TABLE ***************************.test_table AS ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC(ds, day) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Databricks/test_render_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Databricks/test_render_query__query0.sql index c7949f8a59..a3bb3c8e79 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Databricks/test_render_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Databricks/test_render_query__query0.sql @@ -9,7 +9,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Databricks/test_render_write_to_table_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Databricks/test_render_write_to_table_query__query0.sql index 701465ead6..584414321a 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Databricks/test_render_write_to_table_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Databricks/test_render_write_to_table_query__query0.sql @@ -10,7 +10,7 @@ CREATE TABLE ***************************.test_table AS ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/DuckDB/test_render_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/DuckDB/test_render_query__query0.sql index c7949f8a59..a3bb3c8e79 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/DuckDB/test_render_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/DuckDB/test_render_query__query0.sql @@ -9,7 +9,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/DuckDB/test_render_write_to_table_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/DuckDB/test_render_write_to_table_query__query0.sql index 701465ead6..584414321a 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/DuckDB/test_render_write_to_table_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/DuckDB/test_render_write_to_table_query__query0.sql @@ -10,7 +10,7 @@ CREATE TABLE ***************************.test_table AS ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Postgres/test_render_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Postgres/test_render_query__query0.sql index c7949f8a59..a3bb3c8e79 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Postgres/test_render_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Postgres/test_render_query__query0.sql @@ -9,7 +9,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Postgres/test_render_write_to_table_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Postgres/test_render_write_to_table_query__query0.sql index 701465ead6..584414321a 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Postgres/test_render_write_to_table_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Postgres/test_render_write_to_table_query__query0.sql @@ -10,7 +10,7 @@ CREATE TABLE ***************************.test_table AS ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Redshift/test_render_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Redshift/test_render_query__query0.sql index c7949f8a59..a3bb3c8e79 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Redshift/test_render_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Redshift/test_render_query__query0.sql @@ -9,7 +9,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Redshift/test_render_write_to_table_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Redshift/test_render_write_to_table_query__query0.sql index 701465ead6..584414321a 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Redshift/test_render_write_to_table_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Redshift/test_render_write_to_table_query__query0.sql @@ -10,7 +10,7 @@ CREATE TABLE ***************************.test_table AS ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Snowflake/test_render_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Snowflake/test_render_query__query0.sql index c7949f8a59..a3bb3c8e79 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Snowflake/test_render_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Snowflake/test_render_query__query0.sql @@ -9,7 +9,7 @@ FROM ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_1 ) subq_2 diff --git a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Snowflake/test_render_write_to_table_query__query0.sql b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Snowflake/test_render_write_to_table_query__query0.sql index 701465ead6..584414321a 100644 --- a/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Snowflake/test_render_write_to_table_query__query0.sql +++ b/metricflow/test/snapshots/test_rendered_query.py/MetricFlowExplainResult/Snowflake/test_render_write_to_table_query__query0.sql @@ -10,7 +10,7 @@ CREATE TABLE ***************************.test_table AS ( -- Pass Only Elements: -- ['bookings', 'metric_time__day'] SELECT - ds AS metric_time__day + DATE_TRUNC('day', ds) AS metric_time__day , 1 AS bookings FROM ***************************.fct_bookings bookings_source_src_1 ) subq_2