Skip to content

Commit

Permalink
fixup! Build DataflowPlan for custom offset window with most grains
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Dec 18, 2024
1 parent 1a5b5e4 commit 2719954
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions metricflow/dataflow/builder/dataflow_plan_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,11 +671,7 @@ def _build_derived_metric_output_node(
requested_agg_time_dimension_specs=queried_agg_time_dimension_specs,
join_on_time_dimension_spec=self._sort_by_base_granularity(queried_agg_time_dimension_specs)[0],
offset_window=(
metric_spec.offset_window
if metric_spec.offset_window
and metric_spec.offset_window.granularity
not in self._semantic_model_lookup.custom_granularity_names
else None
metric_spec.offset_window if not self._offset_window_is_custom(metric_spec.offset_window) else None
),
offset_to_grain=metric_spec.offset_to_grain,
join_type=SqlJoinType.INNER,
Expand Down Expand Up @@ -1674,9 +1670,7 @@ def _build_aggregated_measure_from_measure_source_node(
join_on_time_dimension_spec=join_on_time_dimension_spec,
offset_window=(
before_aggregation_time_spine_join_description.offset_window
if before_aggregation_time_spine_join_description.offset_window
and before_aggregation_time_spine_join_description.offset_window.granularity
not in self._semantic_model_lookup.custom_granularity_names
if not self._offset_window_is_custom(before_aggregation_time_spine_join_description.offset_window)
else None
),
offset_to_grain=before_aggregation_time_spine_join_description.offset_to_grain,
Expand Down Expand Up @@ -1895,7 +1889,7 @@ def _build_time_spine_node(
required_time_spine_specs = required_time_spine_spec_set.time_dimension_specs

should_dedupe = False
if offset_window and offset_window.granularity in self._semantic_model_lookup._custom_granularities:
if offset_window and self._offset_window_is_custom(offset_window):
time_spine_node = self._build_custom_offset_time_spine_node(
offset_window=offset_window, required_time_spine_specs=required_time_spine_specs
)
Expand Down Expand Up @@ -2000,3 +1994,9 @@ def _determine_time_spine_join_spec(
time_granularity=join_spec_grain, date_part=None
)
return join_on_time_dimension_spec

def _offset_window_is_custom(self, offset_window: Optional[MetricTimeWindow]) -> bool:
return (
offset_window is not None
and offset_window.granularity in self._semantic_model_lookup.custom_granularity_names
)

0 comments on commit 2719954

Please sign in to comment.