Skip to content

Commit

Permalink
Rename checked_sink_node.
Browse files Browse the repository at this point in the history
  • Loading branch information
plypaul committed May 16, 2024
1 parent 6f5dcce commit 73d7566
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 104 deletions.
4 changes: 1 addition & 3 deletions metricflow/dataflow/dataflow_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,5 @@ def __init__(self, sink_nodes: Sequence[DataflowPlanNode], plan_id: Optional[Dag
)

@property
def checked_sink_node(self) -> DataflowPlanNode:
"""If this has a single sink node, return it. Otherwise, raise an exception."""
assert len(self._sink_nodes) == 1, f"Exactly 1 sink node is supported. Got: {self._sink_nodes}"
def sink_node(self) -> DataflowPlanNode: # noqa: D102
return self._sink_nodes[0]
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,12 @@ def visit_metric_time_dimension_transform_node( # noqa: D102
return self._default_base_output_handler(node)

def optimize(self, dataflow_plan: DataflowPlan) -> DataflowPlan: # noqa: D102
optimized_result: OptimizeBranchResult = dataflow_plan.checked_sink_node.accept(self)
optimized_result: OptimizeBranchResult = dataflow_plan.sink_node.accept(self)

logger.log(
level=self._log_level,
msg=f"Optimized:\n\n"
f"{dataflow_plan.checked_sink_node.structure_text()}\n\n"
f"{dataflow_plan.sink_node.structure_text()}\n\n"
f"to:\n\n"
f"{optimized_result.optimized_branch.structure_text()}",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def visit_join_conversion_events_node(self, node: JoinConversionEventsNode) -> i
return self._sum_parents(node)

def count_source_nodes(self, dataflow_plan: DataflowPlan) -> int: # noqa: D102
return dataflow_plan.checked_sink_node.accept(self)
return dataflow_plan.sink_node.accept(self)


def check_optimization( # noqa: D103
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_conversion_rate(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)


Expand Down Expand Up @@ -80,7 +80,7 @@ def test_conversion_rate_with_window(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)


Expand All @@ -106,7 +106,7 @@ def test_conversion_rate_with_no_group_by(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)


Expand All @@ -132,7 +132,7 @@ def test_conversion_count_with_no_group_by(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)


Expand Down Expand Up @@ -166,7 +166,7 @@ def test_conversion_rate_with_constant_properties(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)


Expand Down Expand Up @@ -195,5 +195,5 @@ def test_conversion_metric_join_to_timespine_and_fill_nulls_with_0(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_dimensions_requiring_join(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)


Expand Down Expand Up @@ -66,5 +66,5 @@ def test_dimension_values_with_a_join_and_a_filter(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@ def test_simple_query_with_metric_time_dimension(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)
6 changes: 3 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 @@ -1101,7 +1101,7 @@ def test_compute_metrics_node_ratio_from_multiple_semantic_models(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)


Expand Down Expand Up @@ -1187,7 +1187,7 @@ def test_dimensions_requiring_join(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)


Expand All @@ -1213,5 +1213,5 @@ def test_dimension_with_joined_where_constraint(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_cumulative_metric(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)


Expand Down Expand Up @@ -95,7 +95,7 @@ def test_cumulative_metric_with_time_constraint(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)


Expand Down Expand Up @@ -133,7 +133,7 @@ def test_cumulative_metric_with_non_adjustable_time_filter(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)


Expand All @@ -160,7 +160,7 @@ def test_cumulative_metric_no_ds(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)


Expand Down Expand Up @@ -193,7 +193,7 @@ def test_cumulative_metric_no_window(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)


Expand Down Expand Up @@ -223,7 +223,7 @@ def test_cumulative_metric_no_window_with_time_constraint(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)


Expand Down Expand Up @@ -256,7 +256,7 @@ def test_cumulative_metric_grain_to_date(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)


Expand Down Expand Up @@ -286,7 +286,7 @@ def test_cumulative_metric_month(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=extended_date_dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)


Expand Down Expand Up @@ -315,5 +315,5 @@ def test_cumulative_metric_with_agg_time_dimension(
mf_test_configuration=mf_test_configuration,
dataflow_to_sql_converter=dataflow_to_sql_converter,
sql_client=sql_client,
node=dataflow_plan.checked_sink_node,
node=dataflow_plan.sink_node,
)
Loading

0 comments on commit 73d7566

Please sign in to comment.