Skip to content

Commit

Permalink
Remove duplicative param from JoinToTimeSpineNode
Browse files Browse the repository at this point in the history
We can get this info from one of the other params.
  • Loading branch information
courtneyholcomb committed Oct 24, 2024
1 parent 85dac0f commit 4d234f9
Show file tree
Hide file tree
Showing 22 changed files with 5 additions and 40 deletions.
3 changes: 0 additions & 3 deletions metricflow/dataflow/builder/dataflow_plan_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions metricflow/plan_conversion/dataflow_to_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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] = []
Expand Down
3 changes: 0 additions & 3 deletions tests_metricflow/plan_conversion/test_dataflow_to_sql_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
),
Expand Down Expand Up @@ -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")
),
Expand Down Expand Up @@ -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")
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
<!-- time_granularity=ExpandedTimeGranularity(name='day', base_granularity=DAY), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = INNER -->
<!-- offset_to_grain = MONTH -->
<MetricTimeDimensionTransformNode>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<!-- time_granularity=ExpandedTimeGranularity(name='day', base_granularity=DAY), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = INNER -->
<!-- offset_window = PydanticMetricTimeWindow(count=5, granularity=DAY) -->
<MetricTimeDimensionTransformNode>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<!-- time_granularity=ExpandedTimeGranularity(name='month', base_granularity=MONTH), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = INNER -->
<!-- offset_window = PydanticMetricTimeWindow(count=5, granularity=DAY) -->
<MetricTimeDimensionTransformNode>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
<!-- time_granularity=ExpandedTimeGranularity(name='day', base_granularity=DAY), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = INNER -->
<!-- offset_window = PydanticMetricTimeWindow(count=2, granularity=DAY) -->
<JoinOverTimeRangeNode>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
<!-- time_granularity=ExpandedTimeGranularity(name='day', base_granularity=DAY), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = LEFT_OUTER -->
<AggregateMeasuresNode>
<!-- description = 'Aggregate Measures' -->
Expand Down Expand Up @@ -77,7 +76,6 @@
<!-- time_granularity=ExpandedTimeGranularity(name='day', base_granularity=DAY), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = LEFT_OUTER -->
<AggregateMeasuresNode>
<!-- description = 'Aggregate Measures' -->
Expand All @@ -102,7 +100,6 @@
<!-- time_granularity=ExpandedTimeGranularity(name='day', base_granularity=DAY), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = INNER -->
<!-- offset_window = PydanticMetricTimeWindow(count=14, granularity=DAY) -->
<MetricTimeDimensionTransformNode>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
<!-- time_granularity=ExpandedTimeGranularity(name='day', base_granularity=DAY), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = LEFT_OUTER -->
<!-- time_range_constraint = -->
<!-- TimeRangeConstraint( -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<!-- time_granularity=ExpandedTimeGranularity(name='day', base_granularity=DAY), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = LEFT_OUTER -->
<AggregateMeasuresNode>
<!-- description = 'Aggregate Measures' -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<!-- time_granularity=ExpandedTimeGranularity(name='day', base_granularity=DAY), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = INNER -->
<!-- offset_window = PydanticMetricTimeWindow(count=2, granularity=DAY) -->
<ComputeMetricsNode>
Expand Down Expand Up @@ -60,7 +59,6 @@
<!-- time_granularity=ExpandedTimeGranularity(name='day', base_granularity=DAY), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = INNER -->
<!-- offset_window = PydanticMetricTimeWindow(count=5, granularity=DAY) -->
<MetricTimeDimensionTransformNode>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@
<!-- ), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = INNER -->
<!-- offset_to_grain = MONTH -->
<MetricTimeDimensionTransformNode>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@
<!-- ), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = INNER -->
<!-- offset_window = PydanticMetricTimeWindow(count=1, granularity=WEEK) -->
<MetricTimeDimensionTransformNode>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<!-- time_granularity=ExpandedTimeGranularity(name='day', base_granularity=DAY), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = INNER -->
<!-- offset_to_grain = MONTH -->
<!-- time_range_constraint = -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<!-- time_granularity=ExpandedTimeGranularity(name='day', base_granularity=DAY), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = INNER -->
<!-- offset_window = PydanticMetricTimeWindow(count=10, granularity=DAY) -->
<!-- time_range_constraint = -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<!-- time_granularity=ExpandedTimeGranularity(name='day', base_granularity=DAY), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = INNER -->
<!-- time_range_constraint = -->
<!-- TimeRangeConstraint( -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@
<!-- time_granularity=ExpandedTimeGranularity(name='day', base_granularity=DAY), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = LEFT_OUTER -->
<AggregateMeasuresNode>
<!-- description = 'Aggregate Measures' -->
Expand Down Expand Up @@ -335,7 +334,6 @@
<!-- time_granularity=ExpandedTimeGranularity(name='day', base_granularity=DAY), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = LEFT_OUTER -->
<AggregateMeasuresNode>
<!-- description = 'Aggregate Measures' -->
Expand Down Expand Up @@ -466,7 +464,6 @@
<!-- ), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = INNER -->
<!-- offset_window = -->
<!-- PydanticMetricTimeWindow(count=14, granularity=DAY) -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@
<!-- time_granularity=ExpandedTimeGranularity(name='day', base_granularity=DAY), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = LEFT_OUTER -->
<AggregateMeasuresNode>
<!-- description = 'Aggregate Measures' -->
Expand Down Expand Up @@ -334,7 +333,6 @@
<!-- time_granularity=ExpandedTimeGranularity(name='day', base_granularity=DAY), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = LEFT_OUTER -->
<AggregateMeasuresNode>
<!-- description = 'Aggregate Measures' -->
Expand Down Expand Up @@ -465,7 +463,6 @@
<!-- ), -->
<!-- ), -->
<!-- ) -->
<!-- use_custom_agg_time_dimension = False -->
<!-- join_type = INNER -->
<!-- offset_window = -->
<!-- PydanticMetricTimeWindow(count=14, granularity=DAY) -->
Expand Down
Loading

0 comments on commit 4d234f9

Please sign in to comment.