diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index df912f289..0e02ded58 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -3,7 +3,7 @@ import datetime as dt import logging from collections import OrderedDict -from typing import Callable, Dict, FrozenSet, List, Optional, Sequence, Set, Tuple, TypeVar, Union +from typing import Callable, Dict, FrozenSet, List, Optional, Sequence, Set, Tuple, TypeVar from dbt_semantic_interfaces.enum_extension import assert_values_exhausted from dbt_semantic_interfaces.protocols.metric import MetricInputMeasure, MetricType @@ -39,6 +39,7 @@ from metricflow_semantics.specs.where_filter.where_filter_spec import WhereFilterSpec from metricflow_semantics.sql.sql_join_type import SqlJoinType from metricflow_semantics.sql.sql_table import SqlTable +from metricflow_semantics.time.granularity import ExpandedTimeGranularity from metricflow_semantics.time.time_constants import ISO8601_PYTHON_FORMAT, ISO8601_PYTHON_TS_FORMAT from metricflow_semantics.time.time_spine_source import TIME_SPINE_DATA_SET_DESCRIPTION, TimeSpineSource from typing_extensions import override @@ -349,27 +350,28 @@ def _make_time_spine_data_set( apply_group_by = True for agg_time_dimension_spec in required_time_spine_specs: column_alias = self._column_association_resolver.resolve_spec(agg_time_dimension_spec).column_name - # If the requested granularity is the same as the granularity of the spine, do a direct select. agg_time_grain = agg_time_dimension_spec.time_granularity - if ( - agg_time_grain.base_granularity == time_spine_source.base_granularity - and not agg_time_grain.is_custom_granularity - ): - expr: SqlExpressionNode = base_column_expr + # If there is a date_part selected, apply an EXTRACT() to the base column. + if agg_time_dimension_spec.date_part: + expr: SqlExpressionNode = SqlExtractExpression.create( + date_part=agg_time_dimension_spec.date_part, arg=base_column_expr + ) + # If the requested granularity is the same as the granularity of the spine, do a direct select. + elif agg_time_grain == ExpandedTimeGranularity.from_time_granularity(time_spine_source.base_granularity): + expr = base_column_expr apply_group_by = False + # If the granularity is custom, select the appropriate custom granularity column. elif agg_time_grain.is_custom_granularity: - # If any dimensions require a custom granularity, select the appropriate column. for custom_granularity in time_spine_source.custom_granularities: expr = SqlColumnReferenceExpression.from_table_and_column_names( table_alias=time_spine_table_alias, column_name=custom_granularity.parsed_column_name ) + # Otherwise, apply the requested standard granularity using a DATE_TRUNC() on the base column. else: - # If any dimensions require a different standard granularity, apply a DATE_TRUNC() to the base column. expr = SqlDateTruncExpression.create( time_granularity=agg_time_grain.base_granularity, arg=base_column_expr ) select_columns += (SqlSelectColumn(expr=expr, column_alias=column_alias),) - # TODO: also handle date part. output_instance_set = InstanceSet( time_dimension_instances=tuple( @@ -383,7 +385,7 @@ def _make_time_spine_data_set( associated_columns=(self._column_association_resolver.resolve_spec(spec),), spec=spec, ) - for spec in required_time_spine_specs + for spec in agg_time_dimension_specs ] ) ) @@ -1391,7 +1393,6 @@ def visit_join_to_time_spine_node(self, node: JoinToTimeSpineNode) -> SqlDataSet join_on_time_dimension_sample = included_metric_time_instances[0].spec else: join_on_time_dimension_sample = agg_time_dimension_instances[0].spec - agg_time_dimension_instance_for_join = self._choose_instance_for_time_spine_join( [ instance @@ -1400,11 +1401,13 @@ def visit_join_to_time_spine_node(self, node: JoinToTimeSpineNode) -> SqlDataSet and instance.spec.entity_links == join_on_time_dimension_sample.entity_links ] ) + if agg_time_dimension_instance_for_join not in agg_time_dimension_instances: + agg_time_dimension_instances = (agg_time_dimension_instance_for_join,) + agg_time_dimension_instances # Build time spine data set with just the agg_time_dimension instance needed for the join. time_spine_alias = self._next_unique_table_alias() time_spine_dataset = self._make_time_spine_data_set( - agg_time_dimension_instances=(agg_time_dimension_instance_for_join,), + agg_time_dimension_instances=agg_time_dimension_instances, time_range_constraint=node.time_range_constraint, time_spine_where_constraints=node.time_spine_filters or (), ) @@ -1420,105 +1423,52 @@ def visit_join_to_time_spine_node(self, node: JoinToTimeSpineNode) -> SqlDataSet parent_alias=parent_alias, ) - # Select all instances from the parent data set, EXCEPT agg_time_dimensions. - # The agg_time_dimensions will be selected from the time spine data set. - time_dimensions_to_select_from_parent: Tuple[TimeDimensionInstance, ...] = () - time_dimensions_to_select_from_time_spine: Tuple[TimeDimensionInstance, ...] = () - for time_dimension_instance in parent_data_set.instance_set.time_dimension_instances: - if time_dimension_instance in agg_time_dimension_instances: - time_dimensions_to_select_from_time_spine += (time_dimension_instance,) - else: - time_dimensions_to_select_from_parent += (time_dimension_instance,) - parent_instance_set = InstanceSet( - measure_instances=parent_data_set.instance_set.measure_instances, - dimension_instances=parent_data_set.instance_set.dimension_instances, - time_dimension_instances=time_dimensions_to_select_from_parent, - entity_instances=parent_data_set.instance_set.entity_instances, - metric_instances=parent_data_set.instance_set.metric_instances, - metadata_instances=parent_data_set.instance_set.metadata_instances, - ) - parent_select_columns = create_simple_select_columns_for_instance_sets( - self._column_association_resolver, OrderedDict({parent_alias: parent_instance_set}) - ) - - original_time_spine_dim_instance = time_spine_dataset.instance_for_time_dimension( - agg_time_dimension_instance_for_join.spec - ) - time_spine_column_select_expr: Union[ - SqlColumnReferenceExpression, SqlDateTruncExpression - ] = SqlColumnReferenceExpression.create( - SqlColumnReference( - table_alias=time_spine_alias, column_name=original_time_spine_dim_instance.spec.qualified_name - ) - ) + # Remove time spine instances from parent instance set. + time_spine_instances = time_spine_dataset.instance_set + time_spine_specs = time_spine_instances.spec_set + parent_instance_set = parent_data_set.instance_set.transform(FilterElements(exclude_specs=time_spine_specs)) - time_spine_select_columns = [] - time_spine_dim_instances = [] - where_filter: Optional[SqlExpressionNode] = None + # Build select columns + select_columns = create_simple_select_columns_for_instance_sets( + self._column_association_resolver, + OrderedDict({parent_alias: parent_instance_set, time_spine_alias: time_spine_dataset.instance_set}), + ) # If offset_to_grain is used, will need to filter down to rows that match selected granularities. # Does not apply if one of the granularities selected matches the time spine column granularity. + where_filter: Optional[SqlExpressionNode] = None need_where_filter = ( node.offset_to_grain - and original_time_spine_dim_instance.spec not in node.requested_agg_time_dimension_specs + and agg_time_dimension_instance_for_join.spec not in node.requested_agg_time_dimension_specs ) - - # Add requested granularities (if different from time_spine) and date_parts to time spine column. - for parent_time_dimension_instance in time_dimensions_to_select_from_time_spine: - time_dimension_spec = parent_time_dimension_instance.spec - if ( - time_dimension_spec.time_granularity.base_granularity.to_int() - < original_time_spine_dim_instance.spec.time_granularity.base_granularity.to_int() - ): - raise RuntimeError( - f"Can't join to time spine for a time dimension with a smaller granularity than that of the time " - f"spine column. Got {time_dimension_spec.time_granularity} for time dimension, " - f"{original_time_spine_dim_instance.spec.time_granularity} for time spine." - ) - - # Apply grain to time spine select expression, unless grain already matches original time spine column. - should_skip_date_trunc = ( - time_dimension_spec.time_granularity == original_time_spine_dim_instance.spec.time_granularity - or time_dimension_spec.time_granularity.is_custom_granularity - ) - select_expr: SqlExpressionNode = ( - time_spine_column_select_expr - if should_skip_date_trunc - else SqlDateTruncExpression.create( - time_granularity=time_dimension_spec.time_granularity.base_granularity, - arg=time_spine_column_select_expr, - ) + if need_where_filter: + join_column_expr = SqlColumnReferenceExpression.from_table_and_column_names( + table_alias=time_spine_alias, + column_name=agg_time_dimension_instance_for_join.associated_column.column_name, ) - # Filter down to one row per granularity period requested in the group by. Any other granularities - # included here will be filtered out in later nodes so should not be included in where filter. - if need_where_filter and time_dimension_spec in node.requested_agg_time_dimension_specs: - new_where_filter = SqlComparisonExpression.create( - left_expr=select_expr, comparison=SqlComparison.EQUALS, right_expr=time_spine_column_select_expr - ) - where_filter = ( - SqlLogicalExpression.create(operator=SqlLogicalOperator.OR, args=(where_filter, new_where_filter)) - if where_filter - else new_where_filter - ) - - # Apply date_part to time spine column select expression. - if time_dimension_spec.date_part: - select_expr = SqlExtractExpression.create(date_part=time_dimension_spec.date_part, arg=select_expr) - - time_spine_dim_instance = parent_time_dimension_instance.with_new_defined_from( - original_time_spine_dim_instance.defined_from - ) - time_spine_dim_instances.append(time_spine_dim_instance) - time_spine_select_columns.append( - SqlSelectColumn(expr=select_expr, column_alias=time_spine_dim_instance.associated_column.column_name) - ) - time_spine_instance_set = InstanceSet(time_dimension_instances=tuple(time_spine_dim_instances)) + for time_spine_instance in time_spine_instances.as_tuple: + # Filter down to one row per granularity period requested in the group by. Any other granularities + # included here will be filtered out in later nodes so should not be included in where filter. + if need_where_filter and time_spine_instance.spec in node.requested_agg_time_dimension_specs: + column_to_filter_expr = SqlColumnReferenceExpression.from_table_and_column_names( + table_alias=time_spine_alias, column_name=time_spine_instance.associated_column.column_name + ) + new_where_filter = SqlComparisonExpression.create( + left_expr=column_to_filter_expr, comparison=SqlComparison.EQUALS, right_expr=join_column_expr + ) + where_filter = ( + SqlLogicalExpression.create( + operator=SqlLogicalOperator.OR, args=(where_filter, new_where_filter) + ) + if where_filter + else new_where_filter + ) return SqlDataSet( - instance_set=InstanceSet.merge([time_spine_instance_set, parent_instance_set]), + instance_set=InstanceSet.merge([time_spine_dataset.instance_set, parent_instance_set]), sql_select_node=SqlSelectStatementNode.create( description=node.description, - select_columns=tuple(time_spine_select_columns) + parent_select_columns, + select_columns=select_columns, from_source=time_spine_dataset.checked_sql_select_node, from_source_alias=time_spine_alias, join_descs=(join_description,), diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_all_time_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_all_time_metric_with_non_default_grains__plan0.sql index e84baf76a..a0aef3f65 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_all_time_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_all_time_metric_with_non_default_grains__plan0.sql @@ -47,8 +47,8 @@ FROM ( FROM ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_2.metric_time__week AS metric_time__week + subq_2.metric_time__week AS metric_time__week + , subq_2.metric_time__day AS metric_time__day , subq_2.metric_time__quarter AS metric_time__quarter , subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql index cd33a8bae..5402e81e1 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_multiple_agg_time_dimensions__plan0.sql @@ -24,8 +24,8 @@ FROM ( FROM ( -- Join Self Over Time Range SELECT - subq_2.revenue_instance__ds__day AS revenue_instance__ds__day - , subq_2.revenue_instance__ds__month AS revenue_instance__ds__month + subq_2.revenue_instance__ds__month AS revenue_instance__ds__month + , subq_2.revenue_instance__ds__day AS revenue_instance__ds__day , subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql index 978845887..cebb9730c 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_multiple_metric_time_dimensions__plan0.sql @@ -24,8 +24,8 @@ FROM ( FROM ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_2.metric_time__month AS metric_time__month + subq_2.metric_time__month AS metric_time__month + , subq_2.metric_time__day AS metric_time__day , subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_non_default_grain__plan0.sql index 45d1761dd..36d631aa7 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_metric_with_non_default_grain__plan0.sql @@ -38,8 +38,8 @@ FROM ( FROM ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_2.metric_time__week AS metric_time__week + subq_2.metric_time__week AS metric_time__week + , subq_2.metric_time__day AS metric_time__day , subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_cumulative_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_cumulative_metric_with_non_default_grains__plan0.sql index 7aafd6767..7a713dfea 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_cumulative_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_cumulative_metric_with_non_default_grains__plan0.sql @@ -39,8 +39,8 @@ FROM ( FROM ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_2.metric_time__week AS metric_time__week + subq_2.metric_time__week AS metric_time__week + , subq_2.metric_time__day AS metric_time__day , subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_grain_to_date_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_grain_to_date_metric_with_non_default_grains__plan0.sql index 9367d0ab3..97bbe22d4 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_grain_to_date_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_grain_to_date_metric_with_non_default_grains__plan0.sql @@ -47,9 +47,9 @@ FROM ( FROM ( -- Join Self Over Time Range SELECT - subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter - , subq_2.revenue_instance__ds__year AS revenue_instance__ds__year + subq_2.revenue_instance__ds__year AS revenue_instance__ds__year , subq_2.metric_time__day AS metric_time__day + , subq_2.revenue_instance__ds__quarter AS revenue_instance__ds__quarter , subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_window_metric_with_non_default_grain__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_window_metric_with_non_default_grain__plan0.sql index e51efccea..35a19cbf1 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_window_metric_with_non_default_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_window_metric_with_non_default_grain__plan0.sql @@ -34,8 +34,8 @@ FROM ( FROM ( -- Join Self Over Time Range SELECT - subq_2.metric_time__day AS metric_time__day - , subq_2.metric_time__year AS metric_time__year + subq_2.metric_time__year AS metric_time__year + , subq_2.metric_time__day AS metric_time__day , subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_window_metric_with_non_default_grains__plan0.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_window_metric_with_non_default_grains__plan0.sql index 537eeb865..82753cfe7 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_window_metric_with_non_default_grains__plan0.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_window_metric_with_non_default_grains__plan0.sql @@ -8,39 +8,41 @@ sql_engine: DuckDB --- -- Re-aggregate Metric via Group By SELECT - subq_11.booking__ds__month - , subq_11.metric_time__week + subq_11.metric_time__week + , subq_11.booking__ds__month , subq_11.every_two_days_bookers_fill_nulls_with_0 FROM ( -- Window Function for Metric Re-aggregation SELECT - subq_10.booking__ds__month - , subq_10.metric_time__week + subq_10.metric_time__week + , subq_10.booking__ds__month , FIRST_VALUE(subq_10.every_two_days_bookers_fill_nulls_with_0) OVER ( PARTITION BY - subq_10.booking__ds__month - , subq_10.metric_time__week + subq_10.metric_time__week + , subq_10.booking__ds__month ORDER BY subq_10.metric_time__day ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Compute Metrics via Expressions SELECT - subq_9.booking__ds__month + subq_9.metric_time__week + , subq_9.booking__ds__month , subq_9.metric_time__day - , subq_9.metric_time__week , COALESCE(subq_9.bookers, 0) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('month', subq_7.metric_time__day) AS booking__ds__month + subq_7.metric_time__week AS metric_time__week + , subq_7.booking__ds__month AS booking__ds__month , subq_7.metric_time__day AS metric_time__day - , DATE_TRUNC('week', subq_7.metric_time__day) AS metric_time__week , subq_6.bookers AS bookers FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + DATE_TRUNC('month', subq_8.ds) AS booking__ds__month + , subq_8.ds AS metric_time__day + , DATE_TRUNC('week', subq_8.ds) AS metric_time__week FROM ***************************.mf_time_spine subq_8 ) subq_7 LEFT OUTER JOIN ( @@ -60,9 +62,9 @@ FROM ( FROM ( -- Join Self Over Time Range SELECT - subq_2.booking__ds__month AS booking__ds__month + subq_2.metric_time__week AS metric_time__week + , subq_2.booking__ds__month AS booking__ds__month , subq_2.metric_time__day AS metric_time__day - , subq_2.metric_time__week AS metric_time__week , subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month @@ -380,6 +382,6 @@ FROM ( ) subq_10 ) subq_11 GROUP BY - subq_11.booking__ds__month - , subq_11.metric_time__week + subq_11.metric_time__week + , subq_11.booking__ds__month , subq_11.every_two_days_bookers_fill_nulls_with_0 diff --git a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_window_metric_with_non_default_grains__plan0_optimized.sql b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_window_metric_with_non_default_grains__plan0_optimized.sql index 3e431cfda..82ecd52e4 100644 --- a/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_window_metric_with_non_default_grains__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_cumulative_metric_rendering.py/SqlQueryPlan/DuckDB/test_window_metric_with_non_default_grains__plan0_optimized.sql @@ -8,28 +8,28 @@ sql_engine: DuckDB --- -- Re-aggregate Metric via Group By SELECT - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , every_two_days_bookers_fill_nulls_with_0 FROM ( -- Compute Metrics via Expressions -- Window Function for Metric Re-aggregation SELECT - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , FIRST_VALUE(COALESCE(bookers, 0)) OVER ( PARTITION BY - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month ORDER BY metric_time__day ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) AS every_two_days_bookers_fill_nulls_with_0 FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('month', subq_20.ds) AS booking__ds__month + DATE_TRUNC('week', subq_20.ds) AS metric_time__week + , DATE_TRUNC('month', subq_20.ds) AS booking__ds__month , subq_20.ds AS metric_time__day - , DATE_TRUNC('week', subq_20.ds) AS metric_time__week , subq_18.bookers AS bookers FROM ***************************.mf_time_spine subq_20 LEFT OUTER JOIN ( @@ -60,6 +60,6 @@ FROM ( ) subq_21 ) subq_23 GROUP BY - booking__ds__month - , metric_time__week + metric_time__week + , booking__ds__month , every_two_days_bookers_fill_nulls_with_0 diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/DuckDB/test_offset_metric_with_custom_granularity__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/DuckDB/test_offset_metric_with_custom_granularity__plan0.sql index 6b1d555e9..8bcb72ee2 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/DuckDB/test_offset_metric_with_custom_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/DuckDB/test_offset_metric_with_custom_granularity__plan0.sql @@ -25,8 +25,7 @@ FROM ( -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_2.booking__ds__day AS booking__ds__day - , subq_1.ds__day AS ds__day + subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month , subq_1.ds__quarter AS ds__quarter @@ -102,6 +101,7 @@ FROM ( , subq_1.metric_time__extract_day AS metric_time__extract_day , subq_1.metric_time__extract_dow AS metric_time__extract_dow , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.booking__ds__day AS booking__ds__day , subq_1.listing AS listing , subq_1.guest AS guest , subq_1.host AS host diff --git a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/DuckDB/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/DuckDB/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql index 5c84225ec..186615ae5 100644 --- a/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/DuckDB/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_custom_granularity.py/SqlQueryPlan/DuckDB/test_offset_metric_with_custom_granularity_filter_not_in_group_by__plan0.sql @@ -127,8 +127,7 @@ FROM ( -- Join to Time Spine Dataset -- Join to Custom Granularity Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day + subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month , subq_1.ds__quarter AS ds__quarter @@ -204,6 +203,7 @@ FROM ( , subq_1.metric_time__extract_day AS metric_time__extract_day , subq_1.metric_time__extract_dow AS metric_time__extract_dow , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.metric_time__day AS metric_time__day , subq_1.listing AS listing , subq_1.guest AS guest , subq_1.host AS host diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql index 86d1fbeba..8abef9274 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_cumulative_time_offset_metric_with_time_constraint__plan0.sql @@ -125,8 +125,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day + subq_4.ds__day AS ds__day , subq_4.ds__week AS ds__week , subq_4.ds__month AS ds__month , subq_4.ds__quarter AS ds__quarter @@ -202,6 +201,7 @@ FROM ( , subq_4.metric_time__extract_day AS metric_time__extract_day , subq_4.metric_time__extract_dow AS metric_time__extract_dow , subq_4.metric_time__extract_doy AS metric_time__extract_doy + , subq_5.metric_time__day AS metric_time__day , subq_4.listing AS listing , subq_4.guest AS guest , subq_4.host AS host diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql index ccb81c2d5..0300f1b38 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_month_dimension_and_offset_window__plan0.sql @@ -24,8 +24,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__month AS metric_time__month - , subq_1.ds__month AS ds__month + subq_1.ds__month AS ds__month , subq_1.ds__quarter AS ds__quarter , subq_1.ds__year AS ds__year , subq_1.ds__extract_year AS ds__extract_year @@ -42,6 +41,7 @@ FROM ( , subq_1.metric_time__extract_year AS metric_time__extract_year , subq_1.metric_time__extract_quarter AS metric_time__extract_quarter , subq_1.metric_time__extract_month AS metric_time__extract_month + , subq_2.metric_time__month AS metric_time__month , subq_1.listing AS listing , subq_1.booking_monthly__listing AS booking_monthly__listing , subq_1.bookings_monthly AS bookings_monthly diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0.sql index 965a3e413..c38e005ef 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain__plan0.sql @@ -245,8 +245,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.ds__day AS ds__day + subq_6.ds__day AS ds__day , subq_6.ds__week AS ds__week , subq_6.ds__month AS ds__month , subq_6.ds__quarter AS ds__quarter @@ -322,6 +321,7 @@ FROM ( , subq_6.metric_time__extract_day AS metric_time__extract_day , subq_6.metric_time__extract_dow AS metric_time__extract_dow , subq_6.metric_time__extract_doy AS metric_time__extract_doy + , subq_7.metric_time__day AS metric_time__day , subq_6.listing AS listing , subq_6.guest AS guest , subq_6.host AS host diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql index b4bb83a6a..ddb4d0031 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_to_grain_and_granularity__plan0.sql @@ -245,8 +245,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('week', subq_7.metric_time__day) AS metric_time__week - , subq_6.ds__day AS ds__day + subq_6.ds__day AS ds__day , subq_6.ds__week AS ds__week , subq_6.ds__month AS ds__month , subq_6.ds__quarter AS ds__quarter @@ -312,7 +311,6 @@ FROM ( , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.metric_time__day AS metric_time__day , subq_6.metric_time__month AS metric_time__month , subq_6.metric_time__quarter AS metric_time__quarter , subq_6.metric_time__year AS metric_time__year @@ -322,6 +320,8 @@ FROM ( , subq_6.metric_time__extract_day AS metric_time__extract_day , subq_6.metric_time__extract_dow AS metric_time__extract_dow , subq_6.metric_time__extract_doy AS metric_time__extract_doy + , subq_7.metric_time__day AS metric_time__day + , subq_7.metric_time__week AS metric_time__week , subq_6.listing AS listing , subq_6.guest AS guest , subq_6.host AS host @@ -347,6 +347,7 @@ FROM ( -- Time Spine SELECT subq_8.ds AS metric_time__day + , DATE_TRUNC('week', subq_8.ds) AS metric_time__week FROM ***************************.mf_time_spine subq_8 ) subq_7 INNER JOIN ( @@ -546,7 +547,7 @@ FROM ( ) subq_6 ON DATE_TRUNC('month', subq_7.metric_time__day) = subq_6.metric_time__day - WHERE DATE_TRUNC('week', subq_7.metric_time__day) = subq_7.metric_time__day + WHERE subq_7.metric_time__week = subq_7.metric_time__day ) subq_9 ) subq_10 GROUP BY diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0.sql index e5c8285f3..e6b5348c7 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window__plan0.sql @@ -245,8 +245,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_7.metric_time__day AS metric_time__day - , subq_6.ds__day AS ds__day + subq_6.ds__day AS ds__day , subq_6.ds__week AS ds__week , subq_6.ds__month AS ds__month , subq_6.ds__quarter AS ds__quarter @@ -322,6 +321,7 @@ FROM ( , subq_6.metric_time__extract_day AS metric_time__extract_day , subq_6.metric_time__extract_dow AS metric_time__extract_dow , subq_6.metric_time__extract_doy AS metric_time__extract_doy + , subq_7.metric_time__day AS metric_time__day , subq_6.listing AS listing , subq_6.guest AS guest , subq_6.host AS host diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0.sql index 35df55b84..03e600214 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_granularity__plan0.sql @@ -245,8 +245,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('quarter', subq_7.metric_time__day) AS metric_time__quarter - , subq_6.ds__day AS ds__day + subq_6.ds__day AS ds__day , subq_6.ds__week AS ds__week , subq_6.ds__month AS ds__month , subq_6.ds__quarter AS ds__quarter @@ -312,7 +311,6 @@ FROM ( , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.metric_time__day AS metric_time__day , subq_6.metric_time__week AS metric_time__week , subq_6.metric_time__month AS metric_time__month , subq_6.metric_time__year AS metric_time__year @@ -322,6 +320,8 @@ FROM ( , subq_6.metric_time__extract_day AS metric_time__extract_day , subq_6.metric_time__extract_dow AS metric_time__extract_dow , subq_6.metric_time__extract_doy AS metric_time__extract_doy + , subq_7.metric_time__quarter AS metric_time__quarter + , subq_7.metric_time__day AS metric_time__day , subq_6.listing AS listing , subq_6.guest AS guest , subq_6.host AS host @@ -347,6 +347,7 @@ FROM ( -- Time Spine SELECT subq_8.ds AS metric_time__day + , DATE_TRUNC('quarter', subq_8.ds) AS metric_time__quarter FROM ***************************.mf_time_spine subq_8 ) subq_7 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql index f2414d159..e6d9c3841 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain__plan0.sql @@ -30,8 +30,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day + subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month , subq_1.ds__quarter AS ds__quarter @@ -107,6 +106,7 @@ FROM ( , subq_1.metric_time__extract_day AS metric_time__extract_day , subq_1.metric_time__extract_dow AS metric_time__extract_dow , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.metric_time__day AS metric_time__day , subq_1.listing AS listing , subq_1.guest AS guest , subq_1.host AS host @@ -355,8 +355,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_10.metric_time__day AS metric_time__day - , subq_9.ds__day AS ds__day + subq_9.ds__day AS ds__day , subq_9.ds__week AS ds__week , subq_9.ds__month AS ds__month , subq_9.ds__quarter AS ds__quarter @@ -432,6 +431,7 @@ FROM ( , subq_9.metric_time__extract_day AS metric_time__extract_day , subq_9.metric_time__extract_dow AS metric_time__extract_dow , subq_9.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.metric_time__day AS metric_time__day , subq_9.listing AS listing , subq_9.guest AS guest , subq_9.host AS host diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql index 1205c6d9f..b5d7f24f1 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_offset_to_grain_and_granularity__plan0.sql @@ -30,8 +30,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , subq_1.ds__day AS ds__day + subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month , subq_1.ds__quarter AS ds__quarter @@ -97,7 +96,6 @@ FROM ( , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__day AS metric_time__day , subq_1.metric_time__week AS metric_time__week , subq_1.metric_time__month AS metric_time__month , subq_1.metric_time__quarter AS metric_time__quarter @@ -107,6 +105,8 @@ FROM ( , subq_1.metric_time__extract_day AS metric_time__extract_day , subq_1.metric_time__extract_dow AS metric_time__extract_dow , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.metric_time__day AS metric_time__day + , subq_2.metric_time__year AS metric_time__year , subq_1.listing AS listing , subq_1.guest AS guest , subq_1.host AS host @@ -132,6 +132,7 @@ FROM ( -- Time Spine SELECT subq_3.ds AS metric_time__day + , DATE_TRUNC('year', subq_3.ds) AS metric_time__year FROM ***************************.mf_time_spine subq_3 ) subq_2 INNER JOIN ( @@ -331,7 +332,7 @@ FROM ( ) subq_1 ON DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day - WHERE DATE_TRUNC('year', subq_2.metric_time__day) = subq_2.metric_time__day + WHERE subq_2.metric_time__year = subq_2.metric_time__day ) subq_4 ) subq_5 GROUP BY @@ -356,8 +357,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('year', subq_10.metric_time__day) AS metric_time__year - , subq_9.ds__day AS ds__day + subq_9.ds__day AS ds__day , subq_9.ds__week AS ds__week , subq_9.ds__month AS ds__month , subq_9.ds__quarter AS ds__quarter @@ -423,7 +423,6 @@ FROM ( , subq_9.booking__paid_at__extract_day AS booking__paid_at__extract_day , subq_9.booking__paid_at__extract_dow AS booking__paid_at__extract_dow , subq_9.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_9.metric_time__day AS metric_time__day , subq_9.metric_time__week AS metric_time__week , subq_9.metric_time__month AS metric_time__month , subq_9.metric_time__quarter AS metric_time__quarter @@ -433,6 +432,8 @@ FROM ( , subq_9.metric_time__extract_day AS metric_time__extract_day , subq_9.metric_time__extract_dow AS metric_time__extract_dow , subq_9.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.metric_time__day AS metric_time__day + , subq_10.metric_time__year AS metric_time__year , subq_9.listing AS listing , subq_9.guest AS guest , subq_9.host AS host @@ -458,6 +459,7 @@ FROM ( -- Time Spine SELECT subq_11.ds AS metric_time__day + , DATE_TRUNC('year', subq_11.ds) AS metric_time__year FROM ***************************.mf_time_spine subq_11 ) subq_10 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_time_filter__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_time_filter__plan0.sql index 7fc8e48bd..4fe4e2286 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_time_filter__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_metric_with_offset_window_and_time_filter__plan0.sql @@ -449,8 +449,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_8.metric_time__day AS metric_time__day - , subq_7.ds__day AS ds__day + subq_7.ds__day AS ds__day , subq_7.ds__week AS ds__week , subq_7.ds__month AS ds__month , subq_7.ds__quarter AS ds__quarter @@ -526,6 +525,7 @@ FROM ( , subq_7.metric_time__extract_day AS metric_time__extract_day , subq_7.metric_time__extract_dow AS metric_time__extract_dow , subq_7.metric_time__extract_doy AS metric_time__extract_doy + , subq_8.metric_time__day AS metric_time__day , subq_7.listing AS listing , subq_7.guest AS guest , subq_7.host AS host diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0.sql index fc3297f5e..8c464eee1 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_cumulative_metric__plan0.sql @@ -24,8 +24,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_5.metric_time__day AS metric_time__day - , subq_4.ds__day AS ds__day + subq_4.ds__day AS ds__day , subq_4.ds__week AS ds__week , subq_4.ds__month AS ds__month , subq_4.ds__quarter AS ds__quarter @@ -101,6 +100,7 @@ FROM ( , subq_4.metric_time__extract_day AS metric_time__extract_day , subq_4.metric_time__extract_dow AS metric_time__extract_dow , subq_4.metric_time__extract_doy AS metric_time__extract_doy + , subq_5.metric_time__day AS metric_time__day , subq_4.listing AS listing , subq_4.guest AS guest , subq_4.host AS host diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_agg_time_dim__plan0.sql index a92488400..f6261d6ee 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_agg_time_dim__plan0.sql @@ -30,8 +30,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_2.booking__ds__day AS booking__ds__day - , subq_1.ds__day AS ds__day + subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month , subq_1.ds__quarter AS ds__quarter @@ -107,6 +106,7 @@ FROM ( , subq_1.metric_time__extract_day AS metric_time__extract_day , subq_1.metric_time__extract_dow AS metric_time__extract_dow , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.booking__ds__day AS booking__ds__day , subq_1.listing AS listing , subq_1.guest AS guest , subq_1.host AS host diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0.sql index 289baf57e..244d64614 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_derived_offset_metric_with_one_input_metric__plan0.sql @@ -24,8 +24,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day + subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month , subq_1.ds__quarter AS ds__quarter @@ -101,6 +100,7 @@ FROM ( , subq_1.metric_time__extract_day AS metric_time__extract_day , subq_1.metric_time__extract_dow AS metric_time__extract_dow , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.metric_time__day AS metric_time__day , subq_1.listing AS listing , subq_1.guest AS guest , subq_1.host AS host diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql index 02e47d507..cd95405f7 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_derived_metric_offset_with_joined_where_constraint_not_selected__plan0.sql @@ -56,8 +56,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day + subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month , subq_1.ds__quarter AS ds__quarter @@ -133,6 +132,7 @@ FROM ( , subq_1.metric_time__extract_day AS metric_time__extract_day , subq_1.metric_time__extract_dow AS metric_time__extract_dow , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.metric_time__day AS metric_time__day , subq_1.listing AS listing , subq_1.guest AS guest , subq_1.host AS host diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets__plan0.sql index 5579580ac..409495a94 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets__plan0.sql @@ -40,8 +40,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day + subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month , subq_1.ds__quarter AS ds__quarter @@ -117,6 +116,7 @@ FROM ( , subq_1.metric_time__extract_day AS metric_time__extract_day , subq_1.metric_time__extract_dow AS metric_time__extract_dow , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.metric_time__day AS metric_time__day , subq_1.listing AS listing , subq_1.guest AS guest , subq_1.host AS host diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0.sql index e00e75288..660f8fd8e 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_time_constraint__plan0.sql @@ -41,8 +41,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day + subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month , subq_1.ds__quarter AS ds__quarter @@ -118,6 +117,7 @@ FROM ( , subq_1.metric_time__extract_day AS metric_time__extract_day , subq_1.metric_time__extract_dow AS metric_time__extract_dow , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.metric_time__day AS metric_time__day , subq_1.listing AS listing , subq_1.guest AS guest , subq_1.host AS host diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0.sql index 6faf69f0f..018e76621 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_nested_offsets_with_where_constraint__plan0.sql @@ -45,8 +45,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day + subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month , subq_1.ds__quarter AS ds__quarter @@ -122,6 +121,7 @@ FROM ( , subq_1.metric_time__extract_day AS metric_time__extract_day , subq_1.metric_time__extract_dow AS metric_time__extract_dow , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.metric_time__day AS metric_time__day , subq_1.listing AS listing , subq_1.guest AS guest , subq_1.host AS host diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql index 31d1d67ba..f4113837f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0.sql @@ -26,7 +26,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_4.metric_time__month + subq_4.metric_time__day + , subq_4.metric_time__month , subq_4.ds__day , subq_4.ds__week , subq_4.ds__month @@ -93,7 +94,6 @@ FROM ( , subq_4.booking__paid_at__extract_day , subq_4.booking__paid_at__extract_dow , subq_4.booking__paid_at__extract_doy - , subq_4.metric_time__day , subq_4.metric_time__week , subq_4.metric_time__quarter , subq_4.metric_time__year @@ -127,8 +127,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month - , subq_1.ds__day AS ds__day + subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month , subq_1.ds__quarter AS ds__quarter @@ -194,7 +193,6 @@ FROM ( , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__day AS metric_time__day , subq_1.metric_time__week AS metric_time__week , subq_1.metric_time__quarter AS metric_time__quarter , subq_1.metric_time__year AS metric_time__year @@ -204,6 +202,8 @@ FROM ( , subq_1.metric_time__extract_day AS metric_time__extract_day , subq_1.metric_time__extract_dow AS metric_time__extract_dow , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.metric_time__day AS metric_time__day + , subq_2.metric_time__month AS metric_time__month , subq_1.listing AS listing , subq_1.guest AS guest , subq_1.host AS host @@ -229,6 +229,7 @@ FROM ( -- Time Spine SELECT subq_3.ds AS metric_time__day + , DATE_TRUNC('month', subq_3.ds) AS metric_time__month FROM ***************************.mf_time_spine subq_3 ) subq_2 INNER JOIN ( @@ -428,7 +429,7 @@ FROM ( ) subq_1 ON DATE_TRUNC('month', subq_2.metric_time__day) = subq_1.metric_time__day - WHERE DATE_TRUNC('month', subq_2.metric_time__day) = subq_2.metric_time__day + WHERE subq_2.metric_time__month = subq_2.metric_time__day ) subq_4 WHERE metric_time__day = '2020-01-01' ) subq_5 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index f380958df..29518080d 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -19,8 +19,8 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('month', subq_12.ds) AS metric_time__month - , subq_10.metric_time__day AS metric_time__day + subq_12.ds AS metric_time__day + , DATE_TRUNC('month', subq_12.ds) AS metric_time__month , subq_10.bookings AS bookings FROM ***************************.mf_time_spine subq_12 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_metric_multiple_granularities__plan0.sql index 6f53b5c5f..f96d464b2 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_metric_multiple_granularities__plan0.sql @@ -6,38 +6,35 @@ sql_engine: DuckDB --- -- Compute Metrics via Expressions SELECT - subq_7.metric_time__day - , subq_7.metric_time__month + subq_7.metric_time__month + , subq_7.metric_time__day , subq_7.metric_time__year , bookings_start_of_month AS bookings_at_start_of_month FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.metric_time__month + subq_6.metric_time__month + , subq_6.metric_time__day , subq_6.metric_time__year , subq_6.bookings AS bookings_start_of_month FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , subq_5.metric_time__month + subq_5.metric_time__month + , subq_5.metric_time__day , subq_5.metric_time__year , SUM(subq_5.bookings) AS bookings FROM ( -- Pass Only Elements: ['bookings', 'metric_time__day', 'metric_time__month', 'metric_time__year'] SELECT - subq_4.metric_time__day - , subq_4.metric_time__month + subq_4.metric_time__month + , subq_4.metric_time__day , subq_4.metric_time__year , subq_4.bookings FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month - , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , subq_1.ds__day AS ds__day + subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month , subq_1.ds__quarter AS ds__quarter @@ -111,6 +108,9 @@ FROM ( , subq_1.metric_time__extract_day AS metric_time__extract_day , subq_1.metric_time__extract_dow AS metric_time__extract_dow , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.metric_time__month AS metric_time__month + , subq_2.metric_time__day AS metric_time__day + , subq_2.metric_time__year AS metric_time__year , subq_1.listing AS listing , subq_1.guest AS guest , subq_1.host AS host @@ -136,6 +136,8 @@ FROM ( -- Time Spine SELECT subq_3.ds AS metric_time__day + , DATE_TRUNC('month', subq_3.ds) AS metric_time__month + , DATE_TRUNC('year', subq_3.ds) AS metric_time__year FROM ***************************.mf_time_spine subq_3 ) subq_2 INNER JOIN ( @@ -338,8 +340,8 @@ FROM ( ) subq_4 ) subq_5 GROUP BY - subq_5.metric_time__day - , subq_5.metric_time__month + subq_5.metric_time__month + , subq_5.metric_time__day , subq_5.metric_time__year ) subq_6 ) subq_7 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql index d92697dcf..1624d5626 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_metric_multiple_granularities__plan0_optimized.sql @@ -6,8 +6,8 @@ sql_engine: DuckDB --- -- Compute Metrics via Expressions SELECT - metric_time__day - , metric_time__month + metric_time__month + , metric_time__day , metric_time__year , bookings_start_of_month AS bookings_at_start_of_month FROM ( @@ -16,8 +16,8 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_11.ds AS metric_time__day - , DATE_TRUNC('month', subq_11.ds) AS metric_time__month + DATE_TRUNC('month', subq_11.ds) AS metric_time__month + , subq_11.ds AS metric_time__day , DATE_TRUNC('year', subq_11.ds) AS metric_time__year , SUM(subq_9.bookings) AS bookings_start_of_month FROM ***************************.mf_time_spine subq_11 @@ -32,7 +32,7 @@ FROM ( ON DATE_TRUNC('month', subq_11.ds) = subq_9.metric_time__day GROUP BY - subq_11.ds - , DATE_TRUNC('month', subq_11.ds) + DATE_TRUNC('month', subq_11.ds) + , subq_11.ds , DATE_TRUNC('year', subq_11.ds) ) subq_15 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_with_agg_time_dim__plan0.sql index 0c6691fa2..09b788878 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_to_grain_with_agg_time_dim__plan0.sql @@ -245,8 +245,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_7.booking__ds__day AS booking__ds__day - , subq_6.ds__day AS ds__day + subq_6.ds__day AS ds__day , subq_6.ds__week AS ds__week , subq_6.ds__month AS ds__month , subq_6.ds__quarter AS ds__quarter @@ -322,6 +321,7 @@ FROM ( , subq_6.metric_time__extract_day AS metric_time__extract_day , subq_6.metric_time__extract_dow AS metric_time__extract_dow , subq_6.metric_time__extract_doy AS metric_time__extract_doy + , subq_7.booking__ds__day AS booking__ds__day , subq_6.listing AS listing , subq_6.guest AS guest , subq_6.host AS host diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql index e6cdd5a26..59fd0126f 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_metric_filter_and_query_have_different_granularities__plan0.sql @@ -32,7 +32,8 @@ FROM ( FROM ( -- Constrain Output with WHERE SELECT - subq_4.metric_time__month + subq_4.metric_time__day + , subq_4.metric_time__month , subq_4.ds__day , subq_4.ds__week , subq_4.ds__month @@ -99,7 +100,6 @@ FROM ( , subq_4.booking__paid_at__extract_day , subq_4.booking__paid_at__extract_dow , subq_4.booking__paid_at__extract_doy - , subq_4.metric_time__day , subq_4.metric_time__week , subq_4.metric_time__quarter , subq_4.metric_time__year @@ -133,8 +133,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month - , subq_1.ds__day AS ds__day + subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month , subq_1.ds__quarter AS ds__quarter @@ -200,7 +199,6 @@ FROM ( , subq_1.booking__paid_at__extract_day AS booking__paid_at__extract_day , subq_1.booking__paid_at__extract_dow AS booking__paid_at__extract_dow , subq_1.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_1.metric_time__day AS metric_time__day , subq_1.metric_time__week AS metric_time__week , subq_1.metric_time__quarter AS metric_time__quarter , subq_1.metric_time__year AS metric_time__year @@ -210,6 +208,8 @@ FROM ( , subq_1.metric_time__extract_day AS metric_time__extract_day , subq_1.metric_time__extract_dow AS metric_time__extract_dow , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.metric_time__day AS metric_time__day + , subq_2.metric_time__month AS metric_time__month , subq_1.listing AS listing , subq_1.guest AS guest , subq_1.host AS host @@ -235,6 +235,7 @@ FROM ( -- Time Spine SELECT subq_3.ds AS metric_time__day + , DATE_TRUNC('month', subq_3.ds) AS metric_time__month FROM ***************************.mf_time_spine subq_3 ) subq_2 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql index 84cf6afb8..63f543a97 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_metric_filter_and_query_have_different_granularities__plan0_optimized.sql @@ -25,8 +25,8 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - DATE_TRUNC('month', subq_19.ds) AS metric_time__month - , DATE_TRUNC('day', bookings_source_src_28000.ds) AS metric_time__day + subq_19.ds AS metric_time__day + , DATE_TRUNC('month', subq_19.ds) AS metric_time__month , bookings_source_src_28000.booking_value AS booking_value FROM ***************************.mf_time_spine subq_19 INNER JOIN diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_metric_multiple_granularities__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_metric_multiple_granularities__plan0.sql index 901aaba69..35a848bc4 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_metric_multiple_granularities__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_metric_multiple_granularities__plan0.sql @@ -6,46 +6,43 @@ sql_engine: DuckDB --- -- Compute Metrics via Expressions SELECT - subq_13.metric_time__day - , subq_13.metric_time__month + subq_13.metric_time__month + , subq_13.metric_time__day , subq_13.metric_time__year , booking_value * 0.05 / bookers AS booking_fees_last_week_per_booker_this_week FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) AS metric_time__day - , COALESCE(subq_7.metric_time__month, subq_12.metric_time__month) AS metric_time__month + COALESCE(subq_7.metric_time__month, subq_12.metric_time__month) AS metric_time__month + , COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) AS metric_time__day , COALESCE(subq_7.metric_time__year, subq_12.metric_time__year) AS metric_time__year , MAX(subq_7.booking_value) AS booking_value , MAX(subq_12.bookers) AS bookers FROM ( -- Compute Metrics via Expressions SELECT - subq_6.metric_time__day - , subq_6.metric_time__month + subq_6.metric_time__month + , subq_6.metric_time__day , subq_6.metric_time__year , subq_6.booking_value FROM ( -- Aggregate Measures SELECT - subq_5.metric_time__day - , subq_5.metric_time__month + subq_5.metric_time__month + , subq_5.metric_time__day , subq_5.metric_time__year , SUM(subq_5.booking_value) AS booking_value FROM ( -- Pass Only Elements: ['booking_value', 'metric_time__day', 'metric_time__month', 'metric_time__year'] SELECT - subq_4.metric_time__day - , subq_4.metric_time__month + subq_4.metric_time__month + , subq_4.metric_time__day , subq_4.metric_time__year , subq_4.booking_value FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , DATE_TRUNC('month', subq_2.metric_time__day) AS metric_time__month - , DATE_TRUNC('year', subq_2.metric_time__day) AS metric_time__year - , subq_1.ds__day AS ds__day + subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month , subq_1.ds__quarter AS ds__quarter @@ -119,6 +116,9 @@ FROM ( , subq_1.metric_time__extract_day AS metric_time__extract_day , subq_1.metric_time__extract_dow AS metric_time__extract_dow , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.metric_time__month AS metric_time__month + , subq_2.metric_time__day AS metric_time__day + , subq_2.metric_time__year AS metric_time__year , subq_1.listing AS listing , subq_1.guest AS guest , subq_1.host AS host @@ -144,6 +144,8 @@ FROM ( -- Time Spine SELECT subq_3.ds AS metric_time__day + , DATE_TRUNC('month', subq_3.ds) AS metric_time__month + , DATE_TRUNC('year', subq_3.ds) AS metric_time__year FROM ***************************.mf_time_spine subq_3 ) subq_2 INNER JOIN ( @@ -346,8 +348,8 @@ FROM ( ) subq_4 ) subq_5 GROUP BY - subq_5.metric_time__day - , subq_5.metric_time__month + subq_5.metric_time__month + , subq_5.metric_time__day , subq_5.metric_time__year ) subq_6 ) subq_7 @@ -576,14 +578,14 @@ FROM ( ) subq_12 ON ( - subq_7.metric_time__day = subq_12.metric_time__day - ) AND ( subq_7.metric_time__month = subq_12.metric_time__month + ) AND ( + subq_7.metric_time__day = subq_12.metric_time__day ) AND ( subq_7.metric_time__year = subq_12.metric_time__year ) GROUP BY - COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) - , COALESCE(subq_7.metric_time__month, subq_12.metric_time__month) + COALESCE(subq_7.metric_time__month, subq_12.metric_time__month) + , COALESCE(subq_7.metric_time__day, subq_12.metric_time__day) , COALESCE(subq_7.metric_time__year, subq_12.metric_time__year) ) subq_13 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_metric_multiple_granularities__plan0_optimized.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_metric_multiple_granularities__plan0_optimized.sql index 0c93f0425..eb96fea88 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_metric_multiple_granularities__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_metric_multiple_granularities__plan0_optimized.sql @@ -6,15 +6,15 @@ sql_engine: DuckDB --- -- Compute Metrics via Expressions SELECT - metric_time__day - , metric_time__month + metric_time__month + , metric_time__day , metric_time__year , booking_value * 0.05 / bookers AS booking_fees_last_week_per_booker_this_week FROM ( -- Combine Aggregated Outputs SELECT - COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) AS metric_time__day - , COALESCE(subq_21.metric_time__month, subq_26.metric_time__month) AS metric_time__month + COALESCE(subq_21.metric_time__month, subq_26.metric_time__month) AS metric_time__month + , COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) AS metric_time__day , COALESCE(subq_21.metric_time__year, subq_26.metric_time__year) AS metric_time__year , MAX(subq_21.booking_value) AS booking_value , MAX(subq_26.bookers) AS bookers @@ -24,8 +24,8 @@ FROM ( -- Aggregate Measures -- Compute Metrics via Expressions SELECT - subq_17.ds AS metric_time__day - , DATE_TRUNC('month', subq_17.ds) AS metric_time__month + DATE_TRUNC('month', subq_17.ds) AS metric_time__month + , subq_17.ds AS metric_time__day , DATE_TRUNC('year', subq_17.ds) AS metric_time__year , SUM(bookings_source_src_28000.booking_value) AS booking_value FROM ***************************.mf_time_spine subq_17 @@ -34,8 +34,8 @@ FROM ( ON subq_17.ds - INTERVAL 1 week = DATE_TRUNC('day', bookings_source_src_28000.ds) GROUP BY - subq_17.ds - , DATE_TRUNC('month', subq_17.ds) + DATE_TRUNC('month', subq_17.ds) + , subq_17.ds , DATE_TRUNC('year', subq_17.ds) ) subq_21 FULL OUTER JOIN ( @@ -57,14 +57,14 @@ FROM ( ) subq_26 ON ( - subq_21.metric_time__day = subq_26.metric_time__day - ) AND ( subq_21.metric_time__month = subq_26.metric_time__month + ) AND ( + subq_21.metric_time__day = subq_26.metric_time__day ) AND ( subq_21.metric_time__year = subq_26.metric_time__year ) GROUP BY - COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) - , COALESCE(subq_21.metric_time__month, subq_26.metric_time__month) + COALESCE(subq_21.metric_time__month, subq_26.metric_time__month) + , COALESCE(subq_21.metric_time__day, subq_26.metric_time__day) , COALESCE(subq_21.metric_time__year, subq_26.metric_time__year) ) subq_27 diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_agg_time_dim__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_agg_time_dim__plan0.sql index 975bcd964..4a490f8e3 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_agg_time_dim__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_agg_time_dim__plan0.sql @@ -245,8 +245,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_7.booking__ds__day AS booking__ds__day - , subq_6.ds__day AS ds__day + subq_6.ds__day AS ds__day , subq_6.ds__week AS ds__week , subq_6.ds__month AS ds__month , subq_6.ds__quarter AS ds__quarter @@ -322,6 +321,7 @@ FROM ( , subq_6.metric_time__extract_day AS metric_time__extract_day , subq_6.metric_time__extract_dow AS metric_time__extract_dow , subq_6.metric_time__extract_doy AS metric_time__extract_doy + , subq_7.booking__ds__day AS booking__ds__day , subq_6.listing AS listing , subq_6.guest AS guest , subq_6.host AS host diff --git a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_time_offset_metric_with_time_constraint__plan0.sql b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_time_offset_metric_with_time_constraint__plan0.sql index 623f3e186..cca6a1add 100644 --- a/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_time_offset_metric_with_time_constraint__plan0.sql +++ b/tests_metricflow/snapshots/test_derived_metric_rendering.py/SqlQueryPlan/DuckDB/test_time_offset_metric_with_time_constraint__plan0.sql @@ -24,8 +24,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__day AS metric_time__day - , subq_1.ds__day AS ds__day + subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month , subq_1.ds__quarter AS ds__quarter @@ -101,6 +100,7 @@ FROM ( , subq_1.metric_time__extract_day AS metric_time__extract_day , subq_1.metric_time__extract_dow AS metric_time__extract_dow , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.metric_time__day AS metric_time__day , subq_1.listing AS listing , subq_1.guest AS guest , subq_1.host AS host diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__query_output.txt b/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__query_output.txt index a8724f2db..97205d53b 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__query_output.txt +++ b/tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__query_output.txt @@ -4,3 +4,14 @@ test_filename: test_fill_nulls_with_0.py metric_time__day archived_users_join_to_time_spine ------------------- ----------------------------------- 2020-01-01T00:00:00 12 +2020-01-01T00:00:00 12 +2020-01-01T00:00:00 12 +2020-01-01T00:00:00 12 +2020-01-01T00:00:00 12 +2020-01-01T00:00:00 12 +2020-01-01T00:00:00 12 +2020-01-01T00:00:00 12 +2020-01-01T00:00:00 12 +2020-01-01T00:00:00 12 +2020-01-01T00:00:00 12 +2020-01-01T00:00:00 12 diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0.sql index 805a3ef5e..5ca6b3eb7 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_derived_fill_nulls_for_one_input_metric__plan0.sql @@ -259,8 +259,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_10.metric_time__day AS metric_time__day - , subq_9.ds__day AS ds__day + subq_9.ds__day AS ds__day , subq_9.ds__week AS ds__week , subq_9.ds__month AS ds__month , subq_9.ds__quarter AS ds__quarter @@ -336,6 +335,7 @@ FROM ( , subq_9.metric_time__extract_day AS metric_time__extract_day , subq_9.metric_time__extract_dow AS metric_time__extract_dow , subq_9.metric_time__extract_doy AS metric_time__extract_doy + , subq_10.metric_time__day AS metric_time__day , subq_9.listing AS listing , subq_9.guest AS guest , subq_9.host AS host diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql index 9f67dd098..08183788e 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0.sql @@ -27,8 +27,6 @@ FROM ( ) AND ( metric_time__day = '2020-01-01' ) - GROUP BY - subq_7.metric_time__day ) subq_5 LEFT OUTER JOIN ( -- Aggregate Measures diff --git a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql index 2d0e79cb4..b392fa11e 100644 --- a/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql +++ b/tests_metricflow/snapshots/test_fill_nulls_with_rendering.py/SqlQueryPlan/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__plan0_optimized.sql @@ -23,8 +23,6 @@ FROM ( ) AND ( metric_time__day = '2020-01-01' ) - GROUP BY - metric_time__day ) subq_14 LEFT OUTER JOIN ( -- Constrain Output with WHERE diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0.sql index 4ca895161..34c124092 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_offset_window_with_date_part__plan0.sql @@ -245,8 +245,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - EXTRACT(isodow FROM subq_7.metric_time__day) AS metric_time__extract_dow - , subq_6.ds__day AS ds__day + subq_6.ds__day AS ds__day , subq_6.ds__week AS ds__week , subq_6.ds__month AS ds__month , subq_6.ds__quarter AS ds__quarter @@ -312,7 +311,6 @@ FROM ( , subq_6.booking__paid_at__extract_day AS booking__paid_at__extract_day , subq_6.booking__paid_at__extract_dow AS booking__paid_at__extract_dow , subq_6.booking__paid_at__extract_doy AS booking__paid_at__extract_doy - , subq_6.metric_time__day AS metric_time__day , subq_6.metric_time__week AS metric_time__week , subq_6.metric_time__month AS metric_time__month , subq_6.metric_time__quarter AS metric_time__quarter @@ -322,6 +320,8 @@ FROM ( , subq_6.metric_time__extract_month AS metric_time__extract_month , subq_6.metric_time__extract_day AS metric_time__extract_day , subq_6.metric_time__extract_doy AS metric_time__extract_doy + , subq_7.metric_time__extract_dow AS metric_time__extract_dow + , subq_7.metric_time__day AS metric_time__day , subq_6.listing AS listing , subq_6.guest AS guest , subq_6.host AS host @@ -346,7 +346,8 @@ FROM ( FROM ( -- Time Spine SELECT - subq_8.ds AS metric_time__day + EXTRACT(isodow FROM subq_8.ds) AS metric_time__extract_dow + , subq_8.ds AS metric_time__day FROM ***************************.mf_time_spine subq_8 ) subq_7 INNER JOIN ( diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_to_grain_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_to_grain_metric__plan0.sql index baf5f23c4..8cdfca1fc 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_to_grain_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_to_grain_metric__plan0.sql @@ -24,8 +24,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__hour AS metric_time__hour - , subq_1.ds__day AS ds__day + subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month , subq_1.ds__quarter AS ds__quarter @@ -210,6 +209,7 @@ FROM ( , subq_1.metric_time__extract_day AS metric_time__extract_day , subq_1.metric_time__extract_dow AS metric_time__extract_dow , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.metric_time__hour AS metric_time__hour , subq_1.user AS user , subq_1.home_state AS home_state , subq_1.user__home_state AS user__home_state diff --git a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_window_metric__plan0.sql b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_window_metric__plan0.sql index 30423607d..8d208d527 100644 --- a/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_window_metric__plan0.sql +++ b/tests_metricflow/snapshots/test_granularity_date_part_rendering.py/SqlQueryPlan/DuckDB/test_subdaily_offset_window_metric__plan0.sql @@ -24,8 +24,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_2.metric_time__hour AS metric_time__hour - , subq_1.ds__day AS ds__day + subq_1.ds__day AS ds__day , subq_1.ds__week AS ds__week , subq_1.ds__month AS ds__month , subq_1.ds__quarter AS ds__quarter @@ -210,6 +209,7 @@ FROM ( , subq_1.metric_time__extract_day AS metric_time__extract_day , subq_1.metric_time__extract_dow AS metric_time__extract_dow , subq_1.metric_time__extract_doy AS metric_time__extract_doy + , subq_2.metric_time__hour AS metric_time__hour , subq_1.user AS user , subq_1.home_state AS home_state , subq_1.user__home_state AS user__home_state diff --git a/tests_metricflow/snapshots/test_offset_metrics.py/str/DuckDB/test_offset_to_grain_with_multiple_granularities__query_output.txt b/tests_metricflow/snapshots/test_offset_metrics.py/str/DuckDB/test_offset_to_grain_with_multiple_granularities__query_output.txt index 12d136bed..3e8f5a1fb 100644 --- a/tests_metricflow/snapshots/test_offset_metrics.py/str/DuckDB/test_offset_to_grain_with_multiple_granularities__query_output.txt +++ b/tests_metricflow/snapshots/test_offset_metrics.py/str/DuckDB/test_offset_to_grain_with_multiple_granularities__query_output.txt @@ -1,67 +1,67 @@ test_name: test_offset_to_grain_with_multiple_granularities test_filename: test_offset_metrics.py --- -metric_time__day metric_time__month metric_time__year bookings_at_start_of_month +metric_time__year metric_time__month metric_time__day bookings_at_start_of_month ------------------- -------------------- ------------------- ---------------------------- -2019-12-01T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-02T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-03T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-04T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-05T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-06T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-07T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-08T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-09T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-10T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-11T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-12T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-13T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-14T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-15T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-16T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-17T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-18T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-19T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-20T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-21T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-22T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-23T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-24T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-25T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-26T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-27T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-28T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-29T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-30T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 -2019-12-31T00:00:00 2019-12-01T00:00:00 2019-01-01T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-01T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-02T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-03T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-04T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-05T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-06T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-07T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-08T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-09T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-10T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-11T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-12T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-13T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-14T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-15T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-16T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-17T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-18T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-19T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-20T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-21T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-22T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-23T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-24T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-25T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-26T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-27T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-28T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-29T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-30T00:00:00 1 +2019-01-01T00:00:00 2019-12-01T00:00:00 2019-12-31T00:00:00 1 2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-02T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-03T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-04T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-05T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-06T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-07T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-08T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-09T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-10T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-11T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-12T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-13T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-14T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-15T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-16T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-17T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-18T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-19T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-20T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-21T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-22T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-23T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-24T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-25T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-26T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-27T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-28T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-29T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-30T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 -2020-01-31T00:00:00 2020-01-01T00:00:00 2020-01-01T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-02T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-03T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-04T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-05T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-06T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-07T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-08T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-09T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-10T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-11T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-12T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-13T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-14T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-15T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-16T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-17T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-18T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-19T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-20T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-21T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-22T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-23T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-24T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-25T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-26T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-27T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-28T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-29T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-30T00:00:00 5 +2020-01-01T00:00:00 2020-01-01T00:00:00 2020-01-31T00:00:00 5 diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql index 8d4452f3b..e0a2b34a0 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_fill_nulls_time_spine_metric_predicate_pushdown__plan0.sql @@ -836,8 +836,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_15.metric_time__day AS metric_time__day - , subq_14.ds__day AS ds__day + subq_14.ds__day AS ds__day , subq_14.ds__week AS ds__week , subq_14.ds__month AS ds__month , subq_14.ds__quarter AS ds__quarter @@ -913,6 +912,7 @@ FROM ( , subq_14.metric_time__extract_day AS metric_time__extract_day , subq_14.metric_time__extract_dow AS metric_time__extract_dow , subq_14.metric_time__extract_doy AS metric_time__extract_doy + , subq_15.metric_time__day AS metric_time__day , subq_14.listing AS listing , subq_14.guest AS guest , subq_14.host AS host diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_offset_metric_with_query_time_filters__plan0.sql b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_offset_metric_with_query_time_filters__plan0.sql index d6dec9583..e9da8432b 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_offset_metric_with_query_time_filters__plan0.sql +++ b/tests_metricflow/snapshots/test_predicate_pushdown_rendering.py/SqlQueryPlan/DuckDB/test_offset_metric_with_query_time_filters__plan0.sql @@ -809,8 +809,7 @@ FROM ( FROM ( -- Join to Time Spine Dataset SELECT - subq_12.metric_time__day AS metric_time__day - , subq_11.ds__day AS ds__day + subq_11.ds__day AS ds__day , subq_11.ds__week AS ds__week , subq_11.ds__month AS ds__month , subq_11.ds__quarter AS ds__quarter @@ -886,6 +885,7 @@ FROM ( , subq_11.metric_time__extract_day AS metric_time__extract_day , subq_11.metric_time__extract_dow AS metric_time__extract_dow , subq_11.metric_time__extract_doy AS metric_time__extract_doy + , subq_12.metric_time__day AS metric_time__day , subq_11.listing AS listing , subq_11.guest AS guest , subq_11.host AS host