From e7a24585243424465a18d545f6913b6f1fc5b14d 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 6b619bc73..e8c4124f4 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 392b32fcc..60f245360 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -1208,9 +1208,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), @@ -1967,7 +1967,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( @@ -1987,8 +1987,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,)