Skip to content

Commit

Permalink
Rename SqlQueryPlan to SqlPlan (#1574)
Browse files Browse the repository at this point in the history
Following previous cleanup, this PR renames `SqlQueryPlan` to `SqlPlan`.
The snapshot changes should only be renames, but since it renames a
bunch of files, that commit might be slow to load.
  • Loading branch information
plypaul authored Dec 17, 2024
1 parent 728474d commit aef18d0
Show file tree
Hide file tree
Showing 2,972 changed files with 88 additions and 23,641 deletions.
4 changes: 2 additions & 2 deletions metricflow/plan_conversion/convert_to_sql_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

from metricflow_semantics.instances import InstanceSet

from metricflow.sql.sql_plan import SqlQueryPlan
from metricflow.sql.sql_plan import SqlPlan


@dataclass(frozen=True)
class ConvertToSqlPlanResult:
"""Result object for returning the results of converting to a `SqlQueryPlan`."""

instance_set: InstanceSet
sql_plan: SqlQueryPlan
sql_plan: SqlPlan
4 changes: 2 additions & 2 deletions metricflow/plan_conversion/dataflow_to_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
SqlCteNode,
SqlJoinDescription,
SqlOrderByDescription,
SqlQueryPlan,
SqlPlan,
SqlQueryPlanNode,
SqlSelectColumn,
SqlSelectStatementNode,
Expand Down Expand Up @@ -327,7 +327,7 @@ def convert_using_specifics(

return ConvertToSqlPlanResult(
instance_set=data_set.instance_set,
sql_plan=SqlQueryPlan(render_node=sql_node, plan_id=sql_query_plan_id),
sql_plan=SqlPlan(render_node=sql_node, plan_id=sql_query_plan_id),
)

def _get_nodes_to_convert_to_cte(
Expand Down
4 changes: 2 additions & 2 deletions metricflow/sql/render/sql_plan_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
SqlCteNode,
SqlJoinDescription,
SqlOrderByDescription,
SqlQueryPlan,
SqlPlan,
SqlQueryPlanNode,
SqlQueryPlanNodeVisitor,
SqlSelectColumn,
Expand All @@ -49,7 +49,7 @@ class SqlQueryPlanRenderer(SqlQueryPlanNodeVisitor[SqlPlanRenderResult], ABC):
def _render_node(self, node: SqlQueryPlanNode) -> SqlPlanRenderResult:
return node.accept(self)

def render_sql_query_plan(self, sql_query_plan: SqlQueryPlan) -> SqlPlanRenderResult: # noqa: D102
def render_sql_query_plan(self, sql_query_plan: SqlPlan) -> SqlPlanRenderResult: # noqa: D102
return self._render_node(sql_query_plan.render_node)

@property
Expand Down
8 changes: 4 additions & 4 deletions metricflow/sql/sql_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,14 @@ def nearest_select_columns(
return self.parent_node.nearest_select_columns(cte_source_mapping)


class SqlQueryPlan(MetricFlowDag[SqlQueryPlanNode]):
"""Model for an SQL Query as a DAG."""
class SqlPlan(MetricFlowDag[SqlQueryPlanNode]):
"""Model for an SQL statement as a DAG."""

def __init__(self, render_node: SqlQueryPlanNode, plan_id: Optional[DagId] = None) -> None:
"""Constructor.
"""initializer.
Args:
render_node: The node from which to start rendering the SQL query.
render_node: The node from which to start rendering the SQL statement.
plan_id: If specified, use this sql_query_plan_id instead of a generated one.
"""
self._render_node = render_node
Expand Down
8 changes: 4 additions & 4 deletions tests_metricflow/mf_logging/test_dag_to_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
SqlStringExpression,
)
from metricflow.sql.sql_plan import (
SqlQueryPlan,
SqlPlan,
SqlSelectColumn,
SqlSelectStatementNode,
SqlTableNode,
Expand All @@ -32,7 +32,7 @@ def test_multithread_dag_to_text() -> None:

# Using a nested structure w/ small max_line_length to force recursion / cover recursive width tracking.
dag_to_text_formatter = MetricFlowDagTextFormatter(max_width=1)
dag = SqlQueryPlan(
dag = SqlPlan(
plan_id=DagId("plan"),
render_node=SqlSelectStatementNode.create(
description="test",
Expand Down Expand Up @@ -68,7 +68,7 @@ def _run_mf_pformat() -> None:

expected_thread_output = textwrap.dedent(
"""\
<SqlQueryPlan>
<SqlPlan>
<SqlSelectStatementNode>
<!-- description = -->
<!-- 'test' -->
Expand Down Expand Up @@ -100,7 +100,7 @@ def _run_mf_pformat() -> None:
<!-- 'schema.table' -->
</SqlTableNode>
</SqlSelectStatementNode>
</SqlQueryPlan>
</SqlPlan>
"""
).rstrip()
assert thread_outputs == [expected_thread_output for _ in range(num_threads)]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ test_filename: test_conversion_metrics_to_sql.py
docstring:
Test conversion metric with no group by data flow plan rendering.
---
<SqlQueryPlan>
<SqlPlan>
<SqlSelectStatementNode>
<!-- description = 'Compute Metrics via Expressions' -->
<!-- node_id = NodeId(id_str='ss_15') -->
Expand Down Expand Up @@ -1613,4 +1613,4 @@ docstring:
</SqlSelectStatementNode>
</SqlSelectStatementNode>
</SqlSelectStatementNode>
</SqlQueryPlan>
</SqlPlan>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ test_filename: test_conversion_metrics_to_sql.py
docstring:
Test conversion metric that joins to time spine and fills nulls with 0.
---
<SqlQueryPlan>
<SqlPlan>
<SqlSelectStatementNode>
<!-- description = 'Compute Metrics via Expressions' -->
<!-- node_id = NodeId(id_str='ss_24') -->
Expand Down Expand Up @@ -2002,4 +2002,4 @@ docstring:
</SqlSelectStatementNode>
</SqlSelectStatementNode>
</SqlSelectStatementNode>
</SqlQueryPlan>
</SqlPlan>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ test_filename: test_conversion_metrics_to_sql.py
docstring:
Test conversion metric data flow plan rendering.
---
<SqlQueryPlan>
<SqlPlan>
<SqlSelectStatementNode>
<!-- description = 'Compute Metrics via Expressions' -->
<!-- node_id = NodeId(id_str='ss_15') -->
Expand Down Expand Up @@ -1672,4 +1672,4 @@ docstring:
</SqlSelectStatementNode>
</SqlSelectStatementNode>
</SqlSelectStatementNode>
</SqlQueryPlan>
</SqlPlan>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ test_filename: test_conversion_metrics_to_sql.py
docstring:
Test conversion metric with constant properties by data flow plan rendering.
---
<SqlQueryPlan>
<SqlPlan>
<SqlSelectStatementNode>
<!-- description = 'Compute Metrics via Expressions' -->
<!-- node_id = NodeId(id_str='ss_15') -->
Expand Down Expand Up @@ -1717,4 +1717,4 @@ docstring:
</SqlSelectStatementNode>
</SqlSelectStatementNode>
</SqlSelectStatementNode>
</SqlQueryPlan>
</SqlPlan>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ test_filename: test_conversion_metrics_to_sql.py
docstring:
Test conversion metric with no group by data flow plan rendering.
---
<SqlQueryPlan>
<SqlPlan>
<SqlSelectStatementNode>
<!-- description = 'Compute Metrics via Expressions' -->
<!-- node_id = NodeId(id_str='ss_15') -->
Expand Down Expand Up @@ -1616,4 +1616,4 @@ docstring:
</SqlSelectStatementNode>
</SqlSelectStatementNode>
</SqlSelectStatementNode>
</SqlQueryPlan>
</SqlPlan>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ test_filename: test_conversion_metrics_to_sql.py
docstring:
Test conversion metric with a window data flow plan rendering.
---
<SqlQueryPlan>
<SqlPlan>
<SqlSelectStatementNode>
<!-- description = 'Compute Metrics via Expressions' -->
<!-- node_id = NodeId(id_str='ss_15') -->
Expand Down Expand Up @@ -1704,4 +1704,4 @@ docstring:
</SqlSelectStatementNode>
</SqlSelectStatementNode>
</SqlSelectStatementNode>
</SqlQueryPlan>
</SqlPlan>
Loading

0 comments on commit aef18d0

Please sign in to comment.