From cf3b66d4430e9dd84e6a53d734b968fcb1d67fe9 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Mon, 9 Dec 2024 14:46:51 -0800 Subject: [PATCH] fixup! WIP --- metricflow/dataflow/builder/dataflow_plan_builder.py | 1 - metricflow/plan_conversion/dataflow_to_sql.py | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/metricflow/dataflow/builder/dataflow_plan_builder.py b/metricflow/dataflow/builder/dataflow_plan_builder.py index 8f01180b6..6f5033c3f 100644 --- a/metricflow/dataflow/builder/dataflow_plan_builder.py +++ b/metricflow/dataflow/builder/dataflow_plan_builder.py @@ -1930,7 +1930,6 @@ def _build_time_spine_node( time_spine_node = JoinToCustomGranularityNode.create( parent_node=time_spine_node, time_dimension_spec=custom_spec ) - # TODO: need TransformTimeDimensionsNode in either of the above paths? else: # TODO: support multiple time spines here. Build node on the one with the smallest base grain. # Then, pass custom_granularity_specs into _build_pre_aggregation_plan if they aren't satisfied by smallest time spine. diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index 01a71eba9..bfe93ed6a 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -1209,9 +1209,9 @@ def visit_metric_time_dimension_transform_node(self, node: MetricTimeDimensionTr spec=metric_time_dimension_spec, ) ) - output_column_to_input_column[ - metric_time_dimension_column_association.column_name - ] = matching_time_dimension_instance.associated_column.column_name + output_column_to_input_column[metric_time_dimension_column_association.column_name] = ( + matching_time_dimension_instance.associated_column.column_name + ) output_instance_set = InstanceSet( measure_instances=tuple(output_measure_instances), @@ -1965,7 +1965,7 @@ def visit_cutom_granularity_bounds_node( # noqa: D102 ) # will be node.time_granularity # Build new columns & instances that calculate the start and end of the custom grain. - window_instance = from_data_set.instance_from_time_dimension_grain_and_date_part( + parent_window_instance = from_data_set.instance_from_time_dimension_grain_and_date_part( time_granularity=window_grain, date_part=None ) window_column_expr = SqlColumnReferenceExpression.from_table_and_column_names( @@ -1985,8 +1985,8 @@ def visit_cutom_granularity_bounds_node( # noqa: D102 new_instances: Tuple[TimeDimensionInstance, ...] = () new_select_columns: Tuple[SqlSelectColumn, ...] = () for agg_state, func_args in agg_state_to_func_args.items(): - new_instance = window_instance.with_new_spec( - new_spec=window_instance.spec.with_aggregation_state(agg_state), + new_instance = parent_window_instance.with_new_spec( + new_spec=parent_window_instance.spec.with_aggregation_state(agg_state), column_association_resolver=self._column_association_resolver, ) new_instances += (new_instance,)