From 17bc55e613d33d9897462b5ebb4fabbc6d001008 Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Tue, 27 Aug 2024 11:22:57 -0700 Subject: [PATCH] Add JoinToCustomGranularityNode to DataFlowPlan builder This is blocked by updates to the TimeDimensionSpec, so currently it won't ever get hit. Will update when unblocked. --- .../dataflow/builder/dataflow_plan_builder.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/metricflow/dataflow/builder/dataflow_plan_builder.py b/metricflow/dataflow/builder/dataflow_plan_builder.py index 9538f1c87f..fb499adf93 100644 --- a/metricflow/dataflow/builder/dataflow_plan_builder.py +++ b/metricflow/dataflow/builder/dataflow_plan_builder.py @@ -74,6 +74,7 @@ from metricflow.dataflow.nodes.join_conversion_events import JoinConversionEventsNode from metricflow.dataflow.nodes.join_over_time import JoinOverTimeRangeNode from metricflow.dataflow.nodes.join_to_base import JoinDescription, JoinOnEntitiesNode +from metricflow.dataflow.nodes.join_to_custom_granularity import JoinToCustomGranularityNode from metricflow.dataflow.nodes.join_to_time_spine import JoinToTimeSpineNode from metricflow.dataflow.nodes.min_max import MinMaxNode from metricflow.dataflow.nodes.order_by_limit import OrderByLimitNode @@ -783,6 +784,13 @@ def _build_plan_for_distinct_values( if dataflow_recipe.join_targets: output_node = JoinOnEntitiesNode.create(left_node=output_node, join_targets=dataflow_recipe.join_targets) + for time_dimension_spec in required_linkable_specs.time_dimension_specs: + # TODO: Update conditional when avail - if the time dimension spec has a custom granularity + if False: + output_node = JoinToCustomGranularityNode.create( + parent_node=output_node, time_dimension_spec=time_dimension_spec + ) + if len(query_level_filter_specs) > 0: output_node = WhereConstraintNode.create(parent_node=output_node, where_specs=query_level_filter_specs) if query_spec.time_range_constraint: @@ -1517,6 +1525,13 @@ def _build_aggregated_measure_from_measure_source_node( else: unaggregated_measure_node = filtered_measure_source_node + for time_dimension_spec in queried_linkable_specs.time_dimension_specs: + # TODO: Update conditional when avail - if the time dimension spec has a custom granularity + if False: + unaggregated_measure_node = JoinToCustomGranularityNode.create( + parent_node=unaggregated_measure_node, time_dimension_spec=time_dimension_spec + ) + # If time constraint was previously adjusted for cumulative window or grain, apply original time constraint # here. Can skip if metric is being aggregated over all time. cumulative_metric_constrained_node: Optional[ConstrainTimeRangeNode] = None