Skip to content

Commit

Permalink
Consume only from new cumulative_type_params fields
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Jun 19, 2024
1 parent cf31845 commit 8608b8b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ def _metric_requires_metric_time(self, metric: Metric) -> bool:
metrics_to_check = [metric]
while metrics_to_check:
metric_to_check = metrics_to_check.pop()
if metric_to_check.type_params.window is not None or metric_to_check.type_params.grain_to_date is not None:
if metric_to_check.type_params.cumulative_type_params and (
metric_to_check.type_params.cumulative_type_params.window is not None
or metric_to_check.type_params.cumulative_type_params.grain_to_date is not None
):
return True
for input_metric in metric_to_check.input_metrics:
if input_metric.offset_window is not None or input_metric.offset_to_grain is not None:
Expand Down Expand Up @@ -497,9 +500,11 @@ def _get_metric_time_elements(self, measure_reference: Optional[MeasureReference
dimension_type=DimensionType.TIME,
entity_links=(),
join_path=SemanticModelJoinPath(
left_semantic_model_reference=measure_semantic_model.reference
if measure_semantic_model
else SemanticModelDerivation.VIRTUAL_SEMANTIC_MODEL_REFERENCE,
left_semantic_model_reference=(
measure_semantic_model.reference
if measure_semantic_model
else SemanticModelDerivation.VIRTUAL_SEMANTIC_MODEL_REFERENCE
),
),
# Anything that's not at the base time granularity of the measure's aggregation time dimension
# should be considered derived.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ def validate_metric_in_resolution_dag(
elif metric.type is MetricType.CUMULATIVE:
if (
metric.type_params is not None
and (metric.type_params.window is not None or metric.type_params.grain_to_date is not None)
and metric.type_params.cumulative_type_params is not None
and (
metric.type_params.cumulative_type_params.window is not None
or metric.type_params.cumulative_type_params.grain_to_date is not None
)
and not query_includes_metric_time_or_agg_time_dimension
):
return MetricFlowQueryResolutionIssueSet.from_issue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@
type: cumulative
type_params:
measure: revenue
window: 7 days
cumulative_type_params:
window: 7 days
---
metric:
name: revenue_sub_10
Expand Down
12 changes: 10 additions & 2 deletions metricflow/dataflow/builder/dataflow_plan_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,16 @@ def _build_base_metric_output_node(
child_metric_offset_to_grain=metric_spec.offset_to_grain,
cumulative_description=(
CumulativeMeasureDescription(
cumulative_window=metric.type_params.window,
cumulative_grain_to_date=metric.type_params.grain_to_date,
cumulative_window=(
metric.type_params.cumulative_type_params.window
if metric.type_params.cumulative_type_params
else None
),
cumulative_grain_to_date=(
metric.type_params.cumulative_type_params.grain_to_date
if metric.type_params.cumulative_type_params
else None
),
)
if metric.type is MetricType.CUMULATIVE
else None
Expand Down

0 comments on commit 8608b8b

Please sign in to comment.