From 4d234f93d1d602a7c634d82838f96aad88769404 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Thu, 24 Oct 2024 16:17:28 -0700 Subject: [PATCH] Remove duplicative param from JoinToTimeSpineNode We can get this info from one of the other params. --- metricflow/dataflow/builder/dataflow_plan_builder.py | 3 --- metricflow/plan_conversion/dataflow_to_sql.py | 9 +++++---- .../plan_conversion/test_dataflow_to_sql_plan.py | 3 --- .../test_derived_metric_offset_to_grain__dfp_0.xml | 1 - .../test_derived_metric_offset_window__dfp_0.xml | 1 - ...est_derived_metric_offset_with_granularity__dfp_0.xml | 1 - .../test_derived_offset_cumulative_metric__dfp_0.xml | 1 - .../test_join_to_time_spine_derived_metric__dfp_0.xml | 3 --- .../test_join_to_time_spine_with_filters__dfp_0.xml | 1 - .../test_join_to_time_spine_with_metric_time__dfp_0.xml | 1 - ...st_nested_derived_metric_with_outer_offset__dfp_0.xml | 2 -- ...ter_and_query_have_different_granularities__dfp_0.xml | 1 - ...ter_and_query_have_different_granularities__dfp_0.xml | 1 - ...in_to_time_spine_node_with_offset_to_grain__plan0.xml | 1 - ...join_to_time_spine_node_with_offset_window__plan0.xml | 1 - ...est_join_to_time_spine_node_without_offset__plan0.xml | 1 - ...nulls_time_spine_metric_predicate_pushdown__dfp_0.xml | 3 --- ...ulls_time_spine_metric_predicate_pushdown__dfpo_0.xml | 3 --- ...tric_with_post_agg_join_predicate_pushdown__dfp_0.xml | 3 --- ...ric_with_post_agg_join_predicate_pushdown__dfpo_0.xml | 3 --- .../test_offset_metric_predicate_pushdown__dfp_0.xml | 1 - .../test_offset_metric_predicate_pushdown__dfpo_0.xml | 1 - 22 files changed, 5 insertions(+), 40 deletions(-) diff --git a/metricflow/dataflow/builder/dataflow_plan_builder.py b/metricflow/dataflow/builder/dataflow_plan_builder.py index 856384028c..a91cfdd00c 100644 --- a/metricflow/dataflow/builder/dataflow_plan_builder.py +++ b/metricflow/dataflow/builder/dataflow_plan_builder.py @@ -651,7 +651,6 @@ def _build_derived_metric_output_node( output_node = JoinToTimeSpineNode.create( parent_node=output_node, requested_agg_time_dimension_specs=queried_agg_time_dimension_specs, - use_custom_agg_time_dimension=not queried_linkable_specs.contains_metric_time, time_range_constraint=predicate_pushdown_state.time_range_constraint, offset_window=metric_spec.offset_window, offset_to_grain=metric_spec.offset_to_grain, @@ -1625,7 +1624,6 @@ def _build_aggregated_measure_from_measure_source_node( join_to_time_spine_node = JoinToTimeSpineNode.create( parent_node=time_range_node or measure_recipe.source_node, requested_agg_time_dimension_specs=queried_agg_time_dimension_specs, - use_custom_agg_time_dimension=not queried_linkable_specs.contains_metric_time, time_range_constraint=predicate_pushdown_state.time_range_constraint, offset_window=before_aggregation_time_spine_join_description.offset_window, offset_to_grain=before_aggregation_time_spine_join_description.offset_to_grain, @@ -1764,7 +1762,6 @@ def _build_aggregated_measure_from_measure_source_node( output_node: DataflowPlanNode = JoinToTimeSpineNode.create( parent_node=aggregate_measures_node, requested_agg_time_dimension_specs=queried_agg_time_dimension_specs, - use_custom_agg_time_dimension=not queried_linkable_specs.contains_metric_time, join_type=after_aggregation_time_spine_join_description.join_type, time_range_constraint=predicate_pushdown_state.time_range_constraint, offset_window=after_aggregation_time_spine_join_description.offset_window, diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index a17e4ca2fe..6a386303d7 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -34,6 +34,7 @@ ) from metricflow_semantics.specs.group_by_metric_spec import GroupByMetricSpec from metricflow_semantics.specs.instance_spec import InstanceSpec +from metricflow_semantics.specs.linkable_spec_set import LinkableSpecSet from metricflow_semantics.specs.measure_spec import MeasureSpec from metricflow_semantics.specs.metadata_spec import MetadataSpec from metricflow_semantics.specs.metric_spec import MetricSpec @@ -1312,13 +1313,13 @@ def visit_join_to_time_spine_node(self, node: JoinToTimeSpineNode) -> SqlDataSet parent_data_set = node.parent_node.accept(self) parent_alias = self._next_unique_table_alias() - if node.use_custom_agg_time_dimension: + if LinkableSpecSet.create_from_specs(node.requested_agg_time_dimension_specs).contains_metric_time: + agg_time_element_name = METRIC_TIME_ELEMENT_NAME + agg_time_entity_links = () + else: agg_time_dimension = node.requested_agg_time_dimension_specs[0] agg_time_element_name = agg_time_dimension.element_name agg_time_entity_links: Tuple[EntityReference, ...] = agg_time_dimension.entity_links - else: - agg_time_element_name = METRIC_TIME_ELEMENT_NAME - agg_time_entity_links = () # Find the time dimension instances in the parent data set that match the one we want to join with. agg_time_dimension_instances: List[TimeDimensionInstance] = [] diff --git a/tests_metricflow/plan_conversion/test_dataflow_to_sql_plan.py b/tests_metricflow/plan_conversion/test_dataflow_to_sql_plan.py index a7c45edc0f..65967bceb7 100644 --- a/tests_metricflow/plan_conversion/test_dataflow_to_sql_plan.py +++ b/tests_metricflow/plan_conversion/test_dataflow_to_sql_plan.py @@ -608,7 +608,6 @@ def test_join_to_time_spine_node_without_offset( join_to_time_spine_node = JoinToTimeSpineNode.create( parent_node=compute_metrics_node, requested_agg_time_dimension_specs=[MTD_SPEC_DAY], - use_custom_agg_time_dimension=False, time_range_constraint=TimeRangeConstraint( start_time=as_datetime("2020-01-01"), end_time=as_datetime("2021-01-01") ), @@ -682,7 +681,6 @@ def test_join_to_time_spine_node_with_offset_window( join_to_time_spine_node = JoinToTimeSpineNode.create( parent_node=compute_metrics_node, requested_agg_time_dimension_specs=[MTD_SPEC_DAY], - use_custom_agg_time_dimension=False, time_range_constraint=TimeRangeConstraint( start_time=as_datetime("2020-01-01"), end_time=as_datetime("2021-01-01") ), @@ -757,7 +755,6 @@ def test_join_to_time_spine_node_with_offset_to_grain( join_to_time_spine_node = JoinToTimeSpineNode.create( parent_node=compute_metrics_node, requested_agg_time_dimension_specs=[MTD_SPEC_DAY], - use_custom_agg_time_dimension=False, time_range_constraint=TimeRangeConstraint( start_time=as_datetime("2020-01-01"), end_time=as_datetime("2021-01-01") ), diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml index 095c832da1..6e2eaadcac 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_to_grain__dfp_0.xml @@ -73,7 +73,6 @@ - diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml index f41943ae25..7e9f12967e 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_window__dfp_0.xml @@ -39,7 +39,6 @@ - diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_with_granularity__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_with_granularity__dfp_0.xml index 71adcf6d22..b87d81530d 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_with_granularity__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_metric_offset_with_granularity__dfp_0.xml @@ -39,7 +39,6 @@ - diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml index 02ef115d87..7eaf157881 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_derived_offset_cumulative_metric__dfp_0.xml @@ -40,7 +40,6 @@ - diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml index 210e4669bb..ee03afecd4 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_derived_metric__dfp_0.xml @@ -28,7 +28,6 @@ - @@ -77,7 +76,6 @@ - @@ -102,7 +100,6 @@ - diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_filters__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_filters__dfp_0.xml index 3b7260c7f7..3a7f2c3a93 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_filters__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_filters__dfp_0.xml @@ -66,7 +66,6 @@ - diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_metric_time__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_metric_time__dfp_0.xml index dd6bbcd9ae..e7dc949571 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_metric_time__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_join_to_time_spine_with_metric_time__dfp_0.xml @@ -17,7 +17,6 @@ - diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml index cf63eee579..e3d0c45ab5 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_nested_derived_metric_with_outer_offset__dfp_0.xml @@ -16,7 +16,6 @@ - @@ -60,7 +59,6 @@ - diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_to_grain_metric_filter_and_query_have_different_granularities__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_to_grain_metric_filter_and_query_have_different_granularities__dfp_0.xml index 67d87187d3..67ce955b7c 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_to_grain_metric_filter_and_query_have_different_granularities__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_to_grain_metric_filter_and_query_have_different_granularities__dfp_0.xml @@ -184,7 +184,6 @@ - diff --git a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_window_metric_filter_and_query_have_different_granularities__dfp_0.xml b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_window_metric_filter_and_query_have_different_granularities__dfp_0.xml index 1a9ca252dc..f330d6392e 100644 --- a/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_window_metric_filter_and_query_have_different_granularities__dfp_0.xml +++ b/tests_metricflow/snapshots/test_dataflow_plan_builder.py/DataflowPlan/test_offset_window_metric_filter_and_query_have_different_granularities__dfp_0.xml @@ -190,7 +190,6 @@ - diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/DataflowPlan/test_join_to_time_spine_node_with_offset_to_grain__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/DataflowPlan/test_join_to_time_spine_node_with_offset_to_grain__plan0.xml index 64a7de4ad4..b1f31edb12 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/DataflowPlan/test_join_to_time_spine_node_with_offset_to_grain__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/DataflowPlan/test_join_to_time_spine_node_with_offset_to_grain__plan0.xml @@ -12,7 +12,6 @@ - diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/DataflowPlan/test_join_to_time_spine_node_with_offset_window__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/DataflowPlan/test_join_to_time_spine_node_with_offset_window__plan0.xml index c0ef3ef454..3978b6a99a 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/DataflowPlan/test_join_to_time_spine_node_with_offset_window__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/DataflowPlan/test_join_to_time_spine_node_with_offset_window__plan0.xml @@ -12,7 +12,6 @@ - diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/DataflowPlan/test_join_to_time_spine_node_without_offset__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/DataflowPlan/test_join_to_time_spine_node_without_offset__plan0.xml index 4fe6f30b38..9fc5b7f7db 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/DataflowPlan/test_join_to_time_spine_node_without_offset__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/DataflowPlan/test_join_to_time_spine_node_without_offset__plan0.xml @@ -12,7 +12,6 @@ - diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_predicate_pushdown__dfp_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_predicate_pushdown__dfp_0.xml index 69d306e873..94bf4185cb 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_predicate_pushdown__dfp_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_predicate_pushdown__dfp_0.xml @@ -117,7 +117,6 @@ - @@ -335,7 +334,6 @@ - @@ -466,7 +464,6 @@ - diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_predicate_pushdown__dfpo_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_predicate_pushdown__dfpo_0.xml index 870c0cd355..8596a9f9dd 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_predicate_pushdown__dfpo_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_predicate_pushdown__dfpo_0.xml @@ -117,7 +117,6 @@ - @@ -334,7 +333,6 @@ - @@ -465,7 +463,6 @@ - diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_with_post_agg_join_predicate_pushdown__dfp_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_with_post_agg_join_predicate_pushdown__dfp_0.xml index 5b5e6a53ab..667b0c61b6 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_with_post_agg_join_predicate_pushdown__dfp_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_with_post_agg_join_predicate_pushdown__dfp_0.xml @@ -160,7 +160,6 @@ - @@ -405,7 +404,6 @@ - @@ -520,7 +518,6 @@ - diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_with_post_agg_join_predicate_pushdown__dfpo_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_with_post_agg_join_predicate_pushdown__dfpo_0.xml index 339a77d3ac..5a3bcad08e 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_with_post_agg_join_predicate_pushdown__dfpo_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_fill_nulls_time_spine_metric_with_post_agg_join_predicate_pushdown__dfpo_0.xml @@ -160,7 +160,6 @@ - @@ -404,7 +403,6 @@ - @@ -519,7 +517,6 @@ - diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_offset_metric_predicate_pushdown__dfp_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_offset_metric_predicate_pushdown__dfp_0.xml index 8ec2b8ed76..50ba372e64 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_offset_metric_predicate_pushdown__dfp_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_offset_metric_predicate_pushdown__dfp_0.xml @@ -435,7 +435,6 @@ - diff --git a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_offset_metric_predicate_pushdown__dfpo_0.xml b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_offset_metric_predicate_pushdown__dfpo_0.xml index 75f907acea..4bd7f46ca2 100644 --- a/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_offset_metric_predicate_pushdown__dfpo_0.xml +++ b/tests_metricflow/snapshots/test_predicate_pushdown_optimizer.py/DataflowPlan/test_offset_metric_predicate_pushdown__dfpo_0.xml @@ -434,7 +434,6 @@ -