diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index f9babee20..b670a3727 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -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, @@ -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( diff --git a/metricflow/sql/optimizer/column_pruner.py b/metricflow/sql/optimizer/column_pruner.py index b7f947c17..edfbd4cfd 100644 --- a/metricflow/sql/optimizer/column_pruner.py +++ b/metricflow/sql/optimizer/column_pruner.py @@ -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, @@ -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 diff --git a/metricflow/sql/optimizer/optimization_levels.py b/metricflow/sql/optimizer/optimization_levels.py index e2e39fd1d..a791937c4 100644 --- a/metricflow/sql/optimizer/optimization_levels.py +++ b/metricflow/sql/optimizer/optimization_levels.py @@ -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 @@ -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 @@ -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 diff --git a/metricflow/sql/optimizer/rewriting_sub_query_reducer.py b/metricflow/sql/optimizer/rewriting_sub_query_reducer.py index 61ed9c7ad..410e50cbb 100644 --- a/metricflow/sql/optimizer/rewriting_sub_query_reducer.py +++ b/metricflow/sql/optimizer/rewriting_sub_query_reducer.py @@ -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, @@ -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. diff --git a/metricflow/sql/optimizer/sql_query_plan_optimizer.py b/metricflow/sql/optimizer/sql_query_plan_optimizer.py index 9cad094ca..65b831abc 100644 --- a/metricflow/sql/optimizer/sql_query_plan_optimizer.py +++ b/metricflow/sql/optimizer/sql_query_plan_optimizer.py @@ -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. """ diff --git a/metricflow/sql/optimizer/sub_query_reducer.py b/metricflow/sql/optimizer/sub_query_reducer.py index ba633bcd1..80790a04c 100644 --- a/metricflow/sql/optimizer/sub_query_reducer.py +++ b/metricflow/sql/optimizer/sub_query_reducer.py @@ -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, @@ -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 diff --git a/metricflow/sql/optimizer/table_alias_simplifier.py b/metricflow/sql/optimizer/table_alias_simplifier.py index 85a791cbc..8ec7b23fc 100644 --- a/metricflow/sql/optimizer/table_alias_simplifier.py +++ b/metricflow/sql/optimizer/table_alias_simplifier.py @@ -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, @@ -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 diff --git a/tests_metricflow/sql/optimizer/check_optimizer.py b/tests_metricflow/sql/optimizer/check_optimizer.py index 99f874743..378a11e93 100644 --- a/tests_metricflow/sql/optimizer/check_optimizer.py +++ b/tests_metricflow/sql/optimizer/check_optimizer.py @@ -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 @@ -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: