Skip to content

Commit

Permalink
Rename SqlQueryPlanOptimizer.
Browse files Browse the repository at this point in the history
  • Loading branch information
plypaul committed Dec 18, 2024
1 parent daea2ed commit caee14e
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
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 @@ -111,7 +111,7 @@
SqlGenerationOptionSet,
SqlQueryOptimizationLevel,
)
from metricflow.sql.optimizer.sql_query_plan_optimizer import SqlQueryPlanOptimizer
from metricflow.sql.optimizer.sql_query_plan_optimizer import SqlPlanOptimizer
from metricflow.sql.sql_exprs import (
SqlAggregateFunctionExpression,
SqlBetweenExpression,
Expand Down Expand Up @@ -272,7 +272,7 @@ def convert_using_specifics(
dataflow_plan_node: DataflowPlanNode,
sql_query_plan_id: Optional[DagId],
nodes_to_convert_to_cte: FrozenSet[DataflowPlanNode],
optimizers: Sequence[SqlQueryPlanOptimizer],
optimizers: Sequence[SqlPlanOptimizer],
) -> ConvertToSqlPlanResult:
"""Helper method to convert using specific options. Main use case are tests."""
logger.debug(
Expand Down
4 changes: 2 additions & 2 deletions metricflow/sql/optimizer/column_pruner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing_extensions import override

from metricflow.sql.optimizer.required_column_aliases import SqlMapRequiredColumnAliasesVisitor
from metricflow.sql.optimizer.sql_query_plan_optimizer import SqlQueryPlanOptimizer
from metricflow.sql.optimizer.sql_query_plan_optimizer import SqlPlanOptimizer
from metricflow.sql.optimizer.tag_column_aliases import NodeToColumnAliasMapping
from metricflow.sql.sql_plan import (
SqlCreateTableAsNode,
Expand Down Expand Up @@ -100,7 +100,7 @@ def visit_cte_node(self, node: SqlCteNode) -> SqlPlanNode:
return node.with_new_select(node.select_statement.accept(self))


class SqlColumnPrunerOptimizer(SqlQueryPlanOptimizer):
class SqlColumnPrunerOptimizer(SqlPlanOptimizer):
"""Removes unnecessary columns in the SELECT statements."""

def optimize(self, node: SqlPlanNode) -> SqlPlanNode: # noqa: D102
Expand Down
6 changes: 3 additions & 3 deletions metricflow/sql/optimizer/optimization_levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from metricflow.sql.optimizer.column_pruner import SqlColumnPrunerOptimizer
from metricflow.sql.optimizer.rewriting_sub_query_reducer import SqlRewritingSubQueryReducer
from metricflow.sql.optimizer.sql_query_plan_optimizer import SqlQueryPlanOptimizer
from metricflow.sql.optimizer.sql_query_plan_optimizer import SqlPlanOptimizer
from metricflow.sql.optimizer.sub_query_reducer import SqlSubQueryReducer
from metricflow.sql.optimizer.table_alias_simplifier import SqlTableAliasSimplifier

Expand Down Expand Up @@ -40,7 +40,7 @@ def __lt__(self, other: SqlQueryOptimizationLevel) -> bool: # noqa: D105
class SqlGenerationOptionSet:
"""Defines the different SQL generation optimizers / options that should be used at each level."""

optimizers: Tuple[SqlQueryPlanOptimizer, ...]
optimizers: Tuple[SqlPlanOptimizer, ...]

# Specifies whether CTEs can be used to simplify generated SQL.
allow_cte: bool
Expand All @@ -49,7 +49,7 @@ class SqlGenerationOptionSet:
def options_for_level( # noqa: D102
level: SqlQueryOptimizationLevel, use_column_alias_in_group_by: bool
) -> SqlGenerationOptionSet:
optimizers: Tuple[SqlQueryPlanOptimizer, ...] = ()
optimizers: Tuple[SqlPlanOptimizer, ...] = ()
allow_cte = False
if level is SqlQueryOptimizationLevel.O0:
pass
Expand Down
4 changes: 2 additions & 2 deletions metricflow/sql/optimizer/rewriting_sub_query_reducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from metricflow_semantics.mf_logging.lazy_formattable import LazyFormat
from typing_extensions import override

from metricflow.sql.optimizer.sql_query_plan_optimizer import SqlQueryPlanOptimizer
from metricflow.sql.optimizer.sql_query_plan_optimizer import SqlPlanOptimizer
from metricflow.sql.sql_exprs import (
SqlColumnAliasReferenceExpression,
SqlColumnReference,
Expand Down Expand Up @@ -799,7 +799,7 @@ def visit_create_table_as_node(self, node: SqlCreateTableAsNode) -> SqlPlanNode:
)


class SqlRewritingSubQueryReducer(SqlQueryPlanOptimizer):
class SqlRewritingSubQueryReducer(SqlPlanOptimizer):
"""Simplify queries by eliminating sub-queries when possible by rewriting expressions.
Expressions in the SELECT, GROUP BY, and WHERE are can be rewritten.
Expand Down
4 changes: 2 additions & 2 deletions metricflow/sql/optimizer/sql_query_plan_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from metricflow.sql.sql_plan import SqlPlanNode


class SqlQueryPlanOptimizer(ABC):
"""Optimize the SQL query plan in some way.
class SqlPlanOptimizer(ABC):
"""Optimize the SQL plan in some way.
e.g. a column pruner that removes unnecessary select columns in sub-queries.
"""
Expand Down
4 changes: 2 additions & 2 deletions metricflow/sql/optimizer/sub_query_reducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from typing_extensions import override

from metricflow.sql.optimizer.sql_query_plan_optimizer import SqlQueryPlanOptimizer
from metricflow.sql.optimizer.sql_query_plan_optimizer import SqlPlanOptimizer
from metricflow.sql.sql_exprs import SqlColumnReference, SqlColumnReferenceExpression
from metricflow.sql.sql_plan import (
SqlCreateTableAsNode,
Expand Down Expand Up @@ -208,7 +208,7 @@ def visit_create_table_as_node(self, node: SqlCreateTableAsNode) -> SqlPlanNode:
)


class SqlSubQueryReducer(SqlQueryPlanOptimizer):
class SqlSubQueryReducer(SqlPlanOptimizer):
"""Simplify queries by eliminating sub-queries when possible.
e.g. from
Expand Down
4 changes: 2 additions & 2 deletions metricflow/sql/optimizer/table_alias_simplifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from typing_extensions import override

from metricflow.sql.optimizer.sql_query_plan_optimizer import SqlQueryPlanOptimizer
from metricflow.sql.optimizer.sql_query_plan_optimizer import SqlPlanOptimizer
from metricflow.sql.sql_plan import (
SqlCreateTableAsNode,
SqlCteNode,
Expand Down Expand Up @@ -95,7 +95,7 @@ def visit_create_table_as_node(self, node: SqlCreateTableAsNode) -> SqlPlanNode:
)


class SqlTableAliasSimplifier(SqlQueryPlanOptimizer):
class SqlTableAliasSimplifier(SqlPlanOptimizer):
"""Simplify queries by eliminating table aliases when possible.
e.g. from
Expand Down
4 changes: 2 additions & 2 deletions tests_metricflow/sql/optimizer/check_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration
from metricflow_semantics.test_helpers.snapshot_helpers import assert_str_snapshot_equal

from metricflow.sql.optimizer.sql_query_plan_optimizer import SqlQueryPlanOptimizer
from metricflow.sql.optimizer.sql_query_plan_optimizer import SqlPlanOptimizer
from metricflow.sql.render.sql_plan_renderer import SqlQueryPlanRenderer
from metricflow.sql.sql_plan import SqlPlan, SqlSelectStatementNode

Expand All @@ -18,7 +18,7 @@
def assert_optimizer_result_snapshot_equal(
request: FixtureRequest,
mf_test_configuration: MetricFlowTestConfiguration,
optimizer: SqlQueryPlanOptimizer,
optimizer: SqlPlanOptimizer,
sql_plan_renderer: SqlQueryPlanRenderer,
select_statement: SqlSelectStatementNode,
) -> None:
Expand Down

0 comments on commit caee14e

Please sign in to comment.