From e6c2196ee8b1a2fc4fd39f1744ef82527527e4ee Mon Sep 17 00:00:00 2001 From: Courtney Holcomb Date: Tue, 10 Sep 2024 08:57:34 -0700 Subject: [PATCH] `TimeSpineSource` additions & rename `SqlTableFromClauseNode` -> `SqlTableNode` (#1399) More setup that will be used for rendering custom granularity SQL. Previously, we were never rendering a join with only a table (no subquery), but that will change for custom granularities. Those joins will use this node, which essentially just renders a table name and alias. I've renamed the node to reflect that change. Also adds some functionality to `TimeSpineSource` that will be needed soon. --- .../time/time_spine_source.py | 21 +++++++- metricflow/dataset/convert_semantic_model.py | 8 ++- metricflow/plan_conversion/dataflow_to_sql.py | 4 +- metricflow/sql/optimizer/column_pruner.py | 6 +-- .../optimizer/rewriting_sub_query_reducer.py | 6 +-- metricflow/sql/optimizer/sub_query_reducer.py | 4 +- .../sql/optimizer/table_alias_simplifier.py | 4 +- metricflow/sql/render/sql_plan_renderer.py | 4 +- metricflow/sql/sql_plan.py | 14 ++--- .../dataflow/builder/test_node_data_set.py | 6 +-- .../mf_logging/test_dag_to_text.py | 12 ++--- ...nversion_count_with_no_group_by__plan0.xml | 18 +++---- ...timespine_and_fill_nulls_with_0__plan0.xml | 30 +++++------ .../test_conversion_rate__plan0.xml | 18 +++---- ...n_rate_with_constant_properties__plan0.xml | 18 +++---- ...onversion_rate_with_no_group_by__plan0.xml | 18 +++---- ...est_conversion_rate_with_window__plan0.xml | 18 +++---- .../test_combine_output_node__plan0.xml | 12 ++--- .../test_compute_metrics_node__plan0.xml | 12 ++--- ...o_from_multiple_semantic_models__plan0.xml | 24 ++++----- ...atio_from_single_semantic_model__plan0.xml | 12 ++--- ...ompute_metrics_node_simple_expr__plan0.xml | 12 ++--- .../test_constrain_time_range_node__plan0.xml | 6 +-- ...on_with_joined_where_constraint__plan0.xml | 12 ++--- .../test_dimensions_requiring_join__plan0.xml | 12 ++--- .../SqlQueryPlan/test_filter_node__plan0.xml | 6 +-- ...lter_with_where_constraint_node__plan0.xml | 6 +-- ...spine_node_with_offset_to_grain__plan0.xml | 12 ++--- ...e_spine_node_with_offset_window__plan0.xml | 12 ++--- ..._time_spine_node_without_offset__plan0.xml | 12 ++--- .../test_measure_aggregation_node__plan0.xml | 6 +-- .../test_multi_join_node__plan0.xml | 18 +++---- .../test_order_by_node__plan0.xml | 6 +-- .../test_semi_additive_join_node__plan0.xml | 12 ++--- ...dditive_join_node_with_grouping__plan0.xml | 12 ++--- ...join_node_with_queried_group_by__plan0.xml | 12 ++--- .../test_single_join_node__plan0.xml | 12 ++--- .../SqlQueryPlan/test_source_node__plan0.xml | 6 +-- ...values_with_a_join_and_a_filter__plan0.xml | 12 ++--- .../test_dimensions_requiring_join__plan0.xml | 12 ++--- ...orm_node_using_non_primary_time__plan0.xml | 6 +-- ...ansform_node_using_primary_time__plan0.xml | 6 +-- ...uery_with_metric_time_dimension__plan0.xml | 12 ++--- ...dimensions_with_time_constraint__plan0.xml | 18 +++---- .../test_metric_time_only__plan0.xml | 6 +-- .../test_metric_time_quarter_alone__plan0.xml | 6 +-- ...tric_time_with_other_dimensions__plan0.xml | 18 +++---- .../sql/optimizer/test_column_pruner.py | 28 ++++------ .../test_rewriting_sub_query_reducer.py | 52 +++++-------------- .../sql/optimizer/test_sub_query_reducer.py | 16 ++---- .../optimizer/test_table_alias_simplifier.py | 8 ++- .../sql/test_engine_specific_rendering.py | 14 ++--- tests_metricflow/sql/test_sql_plan_render.py | 24 +++------ 53 files changed, 322 insertions(+), 359 deletions(-) diff --git a/metricflow-semantics/metricflow_semantics/time/time_spine_source.py b/metricflow-semantics/metricflow_semantics/time/time_spine_source.py index 8f7f6744fb..1985369f77 100644 --- a/metricflow-semantics/metricflow_semantics/time/time_spine_source.py +++ b/metricflow-semantics/metricflow_semantics/time/time_spine_source.py @@ -4,6 +4,7 @@ from dataclasses import dataclass from typing import Dict, Optional, Sequence +from dbt_semantic_interfaces.implementations.time_spine import PydanticTimeSpineCustomGranularityColumn from dbt_semantic_interfaces.protocols import SemanticManifest from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity @@ -29,7 +30,7 @@ class TimeSpineSource: # The time granularity of the base column. base_granularity: TimeGranularity = DEFAULT_TIME_GRANULARITY db_name: Optional[str] = None - custom_granularities: Sequence[str] = () + custom_granularities: Sequence[PydanticTimeSpineCustomGranularityColumn] = () @property def spine_table(self) -> SqlTable: @@ -48,7 +49,14 @@ def build_standard_time_spine_sources( db_name=time_spine.node_relation.database, base_column=time_spine.primary_column.name, base_granularity=time_spine.primary_column.time_granularity, - custom_granularities=[column.name for column in time_spine.custom_granularities], + custom_granularities=tuple( + [ + PydanticTimeSpineCustomGranularityColumn( + name=custom_granularity.name, column_name=custom_granularity.column_name + ) + for custom_granularity in time_spine.custom_granularities + ] + ), ) for time_spine in semantic_manifest.project_configuration.time_spines } @@ -74,3 +82,12 @@ def build_standard_time_spine_sources( ) return time_spine_sources + + @staticmethod + def build_custom_time_spine_sources(time_spine_sources: Sequence[TimeSpineSource]) -> Dict[str, TimeSpineSource]: + """Creates a set of time spine sources with custom granularities based on what's in the manifest.""" + return { + custom_granularity.name: time_spine_source + for time_spine_source in time_spine_sources + for custom_granularity in time_spine_source.custom_granularities + } diff --git a/metricflow/dataset/convert_semantic_model.py b/metricflow/dataset/convert_semantic_model.py index 067c5855af..20facf9465 100644 --- a/metricflow/dataset/convert_semantic_model.py +++ b/metricflow/dataset/convert_semantic_model.py @@ -49,7 +49,7 @@ from metricflow.sql.sql_plan import ( SqlSelectColumn, SqlSelectStatementNode, - SqlTableFromClauseNode, + SqlTableNode, ) logger = logging.getLogger(__name__) @@ -491,9 +491,7 @@ def create_sql_source_data_set(self, semantic_model: SemanticModel) -> SemanticM all_select_columns.extend(select_columns) # Generate the "from" clause depending on whether it's an SQL query or an SQL table. - from_source = SqlTableFromClauseNode.create( - sql_table=SqlTable.from_string(semantic_model.node_relation.relation_name) - ) + from_source = SqlTableNode.create(sql_table=SqlTable.from_string(semantic_model.node_relation.relation_name)) select_statement_node = SqlSelectStatementNode.create( description=f"Read Elements From Semantic Model '{semantic_model.name}'", @@ -552,7 +550,7 @@ def build_time_spine_source_data_set(self, time_spine_source: TimeSpineSource) - sql_select_node=SqlSelectStatementNode.create( description=TIME_SPINE_DATA_SET_DESCRIPTION, select_columns=tuple(select_columns), - from_source=SqlTableFromClauseNode.create(sql_table=time_spine_source.spine_table), + from_source=SqlTableNode.create(sql_table=time_spine_source.spine_table), from_source_alias=from_source_alias, ), ) diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index 7b168c4f0c..92e3d33bbe 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -138,7 +138,7 @@ SqlQueryPlanNode, SqlSelectColumn, SqlSelectStatementNode, - SqlTableFromClauseNode, + SqlTableNode, ) logger = logging.getLogger(__name__) @@ -312,7 +312,7 @@ def _make_time_spine_data_set( sql_select_node=SqlSelectStatementNode.create( description=TIME_SPINE_DATA_SET_DESCRIPTION, select_columns=select_columns, - from_source=SqlTableFromClauseNode.create(sql_table=time_spine_source.spine_table), + from_source=SqlTableNode.create(sql_table=time_spine_source.spine_table), from_source_alias=time_spine_table_alias, group_bys=select_columns if apply_group_by else (), where=( diff --git a/metricflow/sql/optimizer/column_pruner.py b/metricflow/sql/optimizer/column_pruner.py index 61bd283bf1..d8a4cf5340 100644 --- a/metricflow/sql/optimizer/column_pruner.py +++ b/metricflow/sql/optimizer/column_pruner.py @@ -16,7 +16,7 @@ SqlSelectColumn, SqlSelectQueryFromClauseNode, SqlSelectStatementNode, - SqlTableFromClauseNode, + SqlTableNode, ) logger = logging.getLogger(__name__) @@ -191,8 +191,8 @@ def visit_select_statement_node(self, node: SqlSelectStatementNode) -> SqlQueryP distinct=node.distinct, ) - def visit_table_from_clause_node(self, node: SqlTableFromClauseNode) -> SqlQueryPlanNode: - """This node is effectively a FROM statement inside a SELECT statement node, so pruning cannot apply.""" + def visit_table_node(self, node: SqlTableNode) -> SqlQueryPlanNode: + """There are no SELECT columns in this node, so pruning cannot apply.""" return node def visit_query_from_clause_node(self, node: SqlSelectQueryFromClauseNode) -> SqlQueryPlanNode: diff --git a/metricflow/sql/optimizer/rewriting_sub_query_reducer.py b/metricflow/sql/optimizer/rewriting_sub_query_reducer.py index e587b6510f..b21f914c3f 100644 --- a/metricflow/sql/optimizer/rewriting_sub_query_reducer.py +++ b/metricflow/sql/optimizer/rewriting_sub_query_reducer.py @@ -25,7 +25,7 @@ SqlSelectColumn, SqlSelectQueryFromClauseNode, SqlSelectStatementNode, - SqlTableFromClauseNode, + SqlTableNode, ) logger = logging.getLogger(__name__) @@ -700,7 +700,7 @@ def visit_select_statement_node(self, node: SqlSelectStatementNode) -> SqlQueryP distinct=parent_select_node.distinct, ) - def visit_table_from_clause_node(self, node: SqlTableFromClauseNode) -> SqlQueryPlanNode: # noqa: D102 + def visit_table_node(self, node: SqlTableNode) -> SqlQueryPlanNode: # noqa: D102 return node def visit_query_from_clause_node(self, node: SqlSelectQueryFromClauseNode) -> SqlQueryPlanNode: # noqa: D102 @@ -764,7 +764,7 @@ def visit_select_statement_node(self, node: SqlSelectStatementNode) -> SqlQueryP distinct=node.distinct, ) - def visit_table_from_clause_node(self, node: SqlTableFromClauseNode) -> SqlQueryPlanNode: # noqa: D102 + def visit_table_node(self, node: SqlTableNode) -> SqlQueryPlanNode: # noqa: D102 return node def visit_query_from_clause_node(self, node: SqlSelectQueryFromClauseNode) -> SqlQueryPlanNode: # noqa: D102 diff --git a/metricflow/sql/optimizer/sub_query_reducer.py b/metricflow/sql/optimizer/sub_query_reducer.py index a3b440cc67..f8f2098fca 100644 --- a/metricflow/sql/optimizer/sub_query_reducer.py +++ b/metricflow/sql/optimizer/sub_query_reducer.py @@ -13,7 +13,7 @@ SqlQueryPlanNodeVisitor, SqlSelectQueryFromClauseNode, SqlSelectStatementNode, - SqlTableFromClauseNode, + SqlTableNode, ) logger = logging.getLogger(__name__) @@ -188,7 +188,7 @@ def visit_select_statement_node(self, node: SqlSelectStatementNode) -> SqlQueryP distinct=parent_select_node.distinct, ) - def visit_table_from_clause_node(self, node: SqlTableFromClauseNode) -> SqlQueryPlanNode: # noqa: D102 + def visit_table_node(self, node: SqlTableNode) -> SqlQueryPlanNode: # noqa: D102 return node def visit_query_from_clause_node(self, node: SqlSelectQueryFromClauseNode) -> SqlQueryPlanNode: # noqa: D102 diff --git a/metricflow/sql/optimizer/table_alias_simplifier.py b/metricflow/sql/optimizer/table_alias_simplifier.py index 9f32cbefa1..6cc2906df7 100644 --- a/metricflow/sql/optimizer/table_alias_simplifier.py +++ b/metricflow/sql/optimizer/table_alias_simplifier.py @@ -12,7 +12,7 @@ SqlSelectColumn, SqlSelectQueryFromClauseNode, SqlSelectStatementNode, - SqlTableFromClauseNode, + SqlTableNode, ) logger = logging.getLogger(__name__) @@ -68,7 +68,7 @@ def visit_select_statement_node(self, node: SqlSelectStatementNode) -> SqlQueryP distinct=node.distinct, ) - def visit_table_from_clause_node(self, node: SqlTableFromClauseNode) -> SqlQueryPlanNode: # noqa: D102 + def visit_table_node(self, node: SqlTableNode) -> SqlQueryPlanNode: # noqa: D102 return node def visit_query_from_clause_node(self, node: SqlSelectQueryFromClauseNode) -> SqlQueryPlanNode: # noqa: D102 diff --git a/metricflow/sql/render/sql_plan_renderer.py b/metricflow/sql/render/sql_plan_renderer.py index 99f4286ab0..7907541c1c 100644 --- a/metricflow/sql/render/sql_plan_renderer.py +++ b/metricflow/sql/render/sql_plan_renderer.py @@ -25,7 +25,7 @@ SqlSelectColumn, SqlSelectQueryFromClauseNode, SqlSelectStatementNode, - SqlTableFromClauseNode, + SqlTableNode, ) logger = logging.getLogger(__name__) @@ -301,7 +301,7 @@ def visit_select_statement_node(self, node: SqlSelectStatementNode) -> SqlPlanRe bind_parameters=combined_params, ) - def visit_table_from_clause_node(self, node: SqlTableFromClauseNode) -> SqlPlanRenderResult: # noqa: D102 + def visit_table_node(self, node: SqlTableNode) -> SqlPlanRenderResult: # noqa: D102 return SqlPlanRenderResult( sql=node.sql_table.sql, bind_parameters=SqlBindParameters(), diff --git a/metricflow/sql/sql_plan.py b/metricflow/sql/sql_plan.py index 4d0d467710..9fdabfc05d 100644 --- a/metricflow/sql/sql_plan.py +++ b/metricflow/sql/sql_plan.py @@ -29,7 +29,7 @@ class SqlQueryPlanNode(DagNode["SqlQueryPlanNode"], ABC): * Statements like ALTER TABLE don't fit well, but they could be modeled as just a single sink node. * SQL queries in where conditions could be modeled as another SqlQueryPlan. * SqlRenderableNode() indicates nodes where plan generation can begin. Generally, this will be all nodes except - the SqlTableFromClauseNode() since my_table.my_column wouldn't be a valid SQL query. + the SqlTableNode() since my_table.my_column wouldn't be a valid SQL query. Is there an existing library that can do this? """ @@ -63,7 +63,7 @@ def visit_select_statement_node(self, node: SqlSelectStatementNode) -> VisitorOu raise NotImplementedError @abstractmethod - def visit_table_from_clause_node(self, node: SqlTableFromClauseNode) -> VisitorOutputT: # noqa: D102 + def visit_table_node(self, node: SqlTableNode) -> VisitorOutputT: # noqa: D102 raise NotImplementedError @abstractmethod @@ -191,14 +191,14 @@ def description(self) -> str: @dataclass(frozen=True) -class SqlTableFromClauseNode(SqlQueryPlanNode): - """An SQL table that can go in the FROM clause.""" +class SqlTableNode(SqlQueryPlanNode): + """An SQL table that can go in the FROM clause or the JOIN clause.""" sql_table: SqlTable @staticmethod - def create(sql_table: SqlTable) -> SqlTableFromClauseNode: # noqa: D102 - return SqlTableFromClauseNode( + def create(sql_table: SqlTable) -> SqlTableNode: # noqa: D102 + return SqlTableNode( parent_nodes=(), sql_table=sql_table, ) @@ -216,7 +216,7 @@ def displayed_properties(self) -> Sequence[DisplayedProperty]: # noqa: D102 return tuple(super().displayed_properties) + (DisplayedProperty("table_id", self.sql_table.sql),) def accept(self, visitor: SqlQueryPlanNodeVisitor[VisitorOutputT]) -> VisitorOutputT: # noqa: D102 - return visitor.visit_table_from_clause_node(self) + return visitor.visit_table_node(self) @property def is_table(self) -> bool: # noqa: D102 diff --git a/tests_metricflow/dataflow/builder/test_node_data_set.py b/tests_metricflow/dataflow/builder/test_node_data_set.py index 86bc84d7d5..c62c255e55 100644 --- a/tests_metricflow/dataflow/builder/test_node_data_set.py +++ b/tests_metricflow/dataflow/builder/test_node_data_set.py @@ -30,7 +30,7 @@ from metricflow.sql.sql_plan import ( SqlSelectColumn, SqlSelectStatementNode, - SqlTableFromClauseNode, + SqlTableNode, ) from tests_metricflow.fixtures.manifest_fixtures import MetricFlowEngineTestFixture, SemanticManifestSetup @@ -77,9 +77,7 @@ def test_no_parent_node_data_set( column_alias="bookings", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="fct_bookings") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="fct_bookings")), from_source_alias="src", ), ) diff --git a/tests_metricflow/mf_logging/test_dag_to_text.py b/tests_metricflow/mf_logging/test_dag_to_text.py index ed2fb4ac73..66b5100e26 100644 --- a/tests_metricflow/mf_logging/test_dag_to_text.py +++ b/tests_metricflow/mf_logging/test_dag_to_text.py @@ -18,7 +18,7 @@ SqlQueryPlan, SqlSelectColumn, SqlSelectStatementNode, - SqlTableFromClauseNode, + SqlTableNode, ) logger = logging.getLogger(__name__) @@ -41,7 +41,7 @@ def test_multithread_dag_to_text() -> None: column_alias="bar", ), ), - from_source=SqlTableFromClauseNode.create(sql_table=SqlTable(schema_name="schema", table_name="table")), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="schema", table_name="table")), from_source_alias="src", ), ) @@ -80,13 +80,13 @@ def _run_mf_pformat() -> None: - - + + - + @@ -97,7 +97,7 @@ def _run_mf_pformat() -> None: - + """ diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_count_with_no_group_by__plan0.xml b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_count_with_no_group_by__plan0.xml index 86e051ae95..9b84078e53 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_count_with_no_group_by__plan0.xml +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_count_with_no_group_by__plan0.xml @@ -378,14 +378,14 @@ - + - + - + @@ -842,14 +842,14 @@ - + - + - + @@ -1403,14 +1403,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.xml b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.xml index 18a94623a9..12cae237f7 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.xml +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_metric_join_to_timespine_and_fill_nulls_with_0__plan0.xml @@ -68,14 +68,14 @@ - + - + - + @@ -469,14 +469,14 @@ - + - + - + @@ -506,14 +506,14 @@ - + - + - + @@ -1008,14 +1008,14 @@ - + - + - + @@ -1569,14 +1569,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate__plan0.xml b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate__plan0.xml index 6c66869cfc..76d275bfed 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate__plan0.xml +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate__plan0.xml @@ -406,14 +406,14 @@ - + - + - + @@ -901,14 +901,14 @@ - + - + - + @@ -1462,14 +1462,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_constant_properties__plan0.xml b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_constant_properties__plan0.xml index 0d74b8ffe5..34cd8e1ee7 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_constant_properties__plan0.xml +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_constant_properties__plan0.xml @@ -429,14 +429,14 @@ - + - + - + @@ -961,14 +961,14 @@ - + - + - + @@ -1522,14 +1522,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_no_group_by__plan0.xml b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_no_group_by__plan0.xml index 98e96bd7bf..5a9ccba69d 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_no_group_by__plan0.xml +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_no_group_by__plan0.xml @@ -381,14 +381,14 @@ - + - + - + @@ -845,14 +845,14 @@ - + - + - + @@ -1406,14 +1406,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_window__plan0.xml b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_window__plan0.xml index 202d16ee1f..e622a820b3 100644 --- a/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_window__plan0.xml +++ b/tests_metricflow/snapshots/test_conversion_metrics_to_sql.py/SqlQueryPlan/test_conversion_rate_with_window__plan0.xml @@ -429,14 +429,14 @@ - + - + - + @@ -949,14 +949,14 @@ - + - + - + @@ -1510,14 +1510,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_combine_output_node__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_combine_output_node__plan0.xml index 933961b64d..f3b4638753 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_combine_output_node__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_combine_output_node__plan0.xml @@ -435,14 +435,14 @@ - + - + - + @@ -851,14 +851,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node__plan0.xml index f411e4014f..e806714fe9 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node__plan0.xml @@ -480,14 +480,14 @@ - + - + - + @@ -764,14 +764,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml index c7b4c40da5..ec6159a6cb 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_multiple_semantic_models__plan0.xml @@ -1098,14 +1098,14 @@ - + - + - + @@ -1749,15 +1749,15 @@ - + - + - + @@ -2426,14 +2426,14 @@ - + - + - + @@ -3077,15 +3077,15 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.xml index a59b15b10c..32566bd296 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_ratio_from_single_semantic_model__plan0.xml @@ -488,14 +488,14 @@ - + - + - + @@ -772,14 +772,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_simple_expr__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_simple_expr__plan0.xml index b49e0adda0..461a04a81e 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_simple_expr__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_compute_metrics_node_simple_expr__plan0.xml @@ -485,14 +485,14 @@ - + - + - + @@ -769,14 +769,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_constrain_time_range_node__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_constrain_time_range_node__plan0.xml index 3dbb6ba474..6176cc9469 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_constrain_time_range_node__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_constrain_time_range_node__plan0.xml @@ -403,14 +403,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimension_with_joined_where_constraint__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimension_with_joined_where_constraint__plan0.xml index 8dd230473f..0c6fb172f0 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimension_with_joined_where_constraint__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimension_with_joined_where_constraint__plan0.xml @@ -645,14 +645,14 @@ - + - + - + @@ -791,14 +791,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimensions_requiring_join__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimensions_requiring_join__plan0.xml index 300613c35e..9db49ce437 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimensions_requiring_join__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_dimensions_requiring_join__plan0.xml @@ -406,14 +406,14 @@ - + - + - + @@ -537,14 +537,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_node__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_node__plan0.xml index b918bd59b9..7454c656d7 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_node__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_node__plan0.xml @@ -262,14 +262,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_with_where_constraint_node__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_with_where_constraint_node__plan0.xml index 1874c79979..cf5619eec8 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_with_where_constraint_node__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_filter_with_where_constraint_node__plan0.xml @@ -335,14 +335,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_with_offset_to_grain__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_with_offset_to_grain__plan0.xml index 6af78e498c..8928db3f68 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_with_offset_to_grain__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_with_offset_to_grain__plan0.xml @@ -20,14 +20,14 @@ - + - + - + @@ -979,14 +979,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_with_offset_window__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_with_offset_window__plan0.xml index 6af78e498c..8928db3f68 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_with_offset_window__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_with_offset_window__plan0.xml @@ -20,14 +20,14 @@ - + - + - + @@ -979,14 +979,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_without_offset__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_without_offset__plan0.xml index 6af78e498c..8928db3f68 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_without_offset__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_join_to_time_spine_node_without_offset__plan0.xml @@ -20,14 +20,14 @@ - + - + - + @@ -979,14 +979,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_aggregation_node__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_aggregation_node__plan0.xml index b09ebddd6b..6755985f55 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_aggregation_node__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_measure_aggregation_node__plan0.xml @@ -358,14 +358,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_join_node__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_join_node__plan0.xml index c4b1c0ba82..3b55dea3fe 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_join_node__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_multi_join_node__plan0.xml @@ -353,14 +353,14 @@ - + - + - + @@ -567,14 +567,14 @@ - + - + - + @@ -781,14 +781,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_order_by_node__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_order_by_node__plan0.xml index 1e77d67666..04959b7430 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_order_by_node__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_order_by_node__plan0.xml @@ -466,14 +466,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node__plan0.xml index 20240bfc48..1aad097e04 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node__plan0.xml @@ -203,14 +203,14 @@ - + - + - + @@ -361,14 +361,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node_with_grouping__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node_with_grouping__plan0.xml index 0df41dcf95..e574ac76b5 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node_with_grouping__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node_with_grouping__plan0.xml @@ -203,14 +203,14 @@ - + - + - + @@ -363,14 +363,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node_with_queried_group_by__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node_with_queried_group_by__plan0.xml index 5f6b8666ce..9f9989cea6 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node_with_queried_group_by__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_semi_additive_join_node_with_queried_group_by__plan0.xml @@ -203,14 +203,14 @@ - + - + - + @@ -363,14 +363,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_single_join_node__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_single_join_node__plan0.xml index b48eaf8fbc..6fd9ff0320 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_single_join_node__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_single_join_node__plan0.xml @@ -342,14 +342,14 @@ - + - + - + @@ -560,14 +560,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_source_node__plan0.xml b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_source_node__plan0.xml index eb50a8c932..e96f0a3b94 100644 --- a/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_source_node__plan0.xml +++ b/tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlQueryPlan/test_source_node__plan0.xml @@ -194,13 +194,13 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimension_values_with_a_join_and_a_filter__plan0.xml b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimension_values_with_a_join_and_a_filter__plan0.xml index 6e100f3b8a..610ab841f2 100644 --- a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimension_values_with_a_join_and_a_filter__plan0.xml +++ b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimension_values_with_a_join_and_a_filter__plan0.xml @@ -649,14 +649,14 @@ - + - + - + @@ -795,14 +795,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimensions_requiring_join__plan0.xml b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimensions_requiring_join__plan0.xml index 300613c35e..9db49ce437 100644 --- a/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimensions_requiring_join__plan0.xml +++ b/tests_metricflow/snapshots/test_distinct_values_to_sql.py/SqlQueryPlan/test_dimensions_requiring_join__plan0.xml @@ -406,14 +406,14 @@ - + - + - + @@ -537,14 +537,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.xml b/tests_metricflow/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.xml index 63551a11fe..ac04ee9750 100644 --- a/tests_metricflow/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.xml +++ b/tests_metricflow/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_metric_time_dimension_transform_node_using_non_primary_time__plan0.xml @@ -484,14 +484,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_metric_time_dimension_transform_node_using_primary_time__plan0.xml b/tests_metricflow/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_metric_time_dimension_transform_node_using_primary_time__plan0.xml index a9ed1f6acb..dc051c89ec 100644 --- a/tests_metricflow/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_metric_time_dimension_transform_node_using_primary_time__plan0.xml +++ b/tests_metricflow/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_metric_time_dimension_transform_node_using_primary_time__plan0.xml @@ -511,14 +511,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_simple_query_with_metric_time_dimension__plan0.xml b/tests_metricflow/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_simple_query_with_metric_time_dimension__plan0.xml index 16ec88a413..cbbc25a9f4 100644 --- a/tests_metricflow/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_simple_query_with_metric_time_dimension__plan0.xml +++ b/tests_metricflow/snapshots/test_metric_time_dimension_to_sql.py/SqlQueryPlan/test_simple_query_with_metric_time_dimension__plan0.xml @@ -972,14 +972,14 @@ - + - + - + @@ -1878,14 +1878,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_dimensions_with_time_constraint__plan0.xml b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_dimensions_with_time_constraint__plan0.xml index b3edf37123..a58dbae4b7 100644 --- a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_dimensions_with_time_constraint__plan0.xml +++ b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_dimensions_with_time_constraint__plan0.xml @@ -663,14 +663,14 @@ - + - + - + @@ -836,14 +836,14 @@ - + - + - + @@ -984,14 +984,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_metric_time_only__plan0.xml b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_metric_time_only__plan0.xml index 19e8aede9e..d609136c15 100644 --- a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_metric_time_only__plan0.xml +++ b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_metric_time_only__plan0.xml @@ -87,14 +87,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_metric_time_quarter_alone__plan0.xml b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_metric_time_quarter_alone__plan0.xml index 740834612f..b6961d9abc 100644 --- a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_metric_time_quarter_alone__plan0.xml +++ b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_metric_time_quarter_alone__plan0.xml @@ -88,14 +88,14 @@ - + - + - + diff --git a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_metric_time_with_other_dimensions__plan0.xml b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_metric_time_with_other_dimensions__plan0.xml index c55d744387..d2d7dfcf8e 100644 --- a/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_metric_time_with_other_dimensions__plan0.xml +++ b/tests_metricflow/snapshots/test_metric_time_without_metrics.py/SqlQueryPlan/test_metric_time_with_other_dimensions__plan0.xml @@ -419,14 +419,14 @@ - + - + - + @@ -579,14 +579,14 @@ - + - + - + @@ -712,14 +712,14 @@ - + - + - + diff --git a/tests_metricflow/sql/optimizer/test_column_pruner.py b/tests_metricflow/sql/optimizer/test_column_pruner.py index 89b2b68fd8..53b4bc3c51 100644 --- a/tests_metricflow/sql/optimizer/test_column_pruner.py +++ b/tests_metricflow/sql/optimizer/test_column_pruner.py @@ -21,7 +21,7 @@ SqlQueryPlanNode, SqlSelectColumn, SqlSelectStatementNode, - SqlTableFromClauseNode, + SqlTableNode, ) from tests_metricflow.sql.compare_sql_plan import assert_default_rendered_sql_equal @@ -141,9 +141,7 @@ def base_select_statement() -> SqlSelectStatementNode: column_alias="join_col", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="from_source_table") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="from_source_table")), from_source_alias="from_source_table", ), from_source_alias="from_source", @@ -180,7 +178,7 @@ def base_select_statement() -> SqlSelectStatementNode: column_alias="join_col", ), ), - from_source=SqlTableFromClauseNode.create( + from_source=SqlTableNode.create( sql_table=SqlTable(schema_name="demo", table_name="joined_source_table") ), from_source_alias="joined_source_table", @@ -529,9 +527,7 @@ def string_select_statement() -> SqlSelectStatementNode: column_alias="join_col", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="from_source_table") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="from_source_table")), from_source_alias="from_source_table", ), from_source_alias="from_source", @@ -568,7 +564,7 @@ def string_select_statement() -> SqlSelectStatementNode: column_alias="join_col", ), ), - from_source=SqlTableFromClauseNode.create( + from_source=SqlTableNode.create( sql_table=SqlTable(schema_name="demo", table_name="joined_source_table") ), from_source_alias="joined_source_table", @@ -698,7 +694,7 @@ def grandparent_pruning_select_statement() -> SqlSelectStatementNode: column_alias="col2", ), ), - from_source=SqlTableFromClauseNode.create(sql_table=SqlTable(schema_name="demo", table_name="src0")), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="src0")), from_source_alias="src0", ), from_source_alias="src1", @@ -765,9 +761,7 @@ def join_grandparent_pruning_select_statement() -> SqlSelectStatementNode: column_alias="col0", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="from_source_table") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="from_source_table")), from_source_alias="src3", join_descs=( SqlJoinDescription( @@ -824,9 +818,7 @@ def join_grandparent_pruning_select_statement() -> SqlSelectStatementNode: column_alias="join_col", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="src0") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="src0")), from_source_alias="src0", ), from_source_alias="src1", @@ -902,9 +894,7 @@ def test_prune_distinct_select( column_alias="bookings", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="fct_bookings") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="fct_bookings")), from_source_alias="a", distinct=True, ), diff --git a/tests_metricflow/sql/optimizer/test_rewriting_sub_query_reducer.py b/tests_metricflow/sql/optimizer/test_rewriting_sub_query_reducer.py index 82ac8e20a9..e4673891f9 100644 --- a/tests_metricflow/sql/optimizer/test_rewriting_sub_query_reducer.py +++ b/tests_metricflow/sql/optimizer/test_rewriting_sub_query_reducer.py @@ -22,7 +22,7 @@ SqlOrderByDescription, SqlSelectColumn, SqlSelectStatementNode, - SqlTableFromClauseNode, + SqlTableNode, ) from tests_metricflow.sql.compare_sql_plan import assert_default_rendered_sql_equal @@ -113,9 +113,7 @@ def base_select_statement() -> SqlSelectStatementNode: column_alias="ds", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="fct_bookings") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="fct_bookings")), from_source_alias="src0", limit=2, ), @@ -263,9 +261,7 @@ def join_select_statement() -> SqlSelectStatementNode: column_alias="listing", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="fct_bookings") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="fct_bookings")), from_source_alias="fct_bookings_src", ), from_source_alias="bookings_src", @@ -287,9 +283,7 @@ def join_select_statement() -> SqlSelectStatementNode: column_alias="listing", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="dim_listings") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="dim_listings")), from_source_alias="dim_listings_src", ), right_source_alias="listings_src", @@ -426,9 +420,7 @@ def colliding_select_statement() -> SqlSelectStatementNode: column_alias="listing", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="fct_bookings") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="fct_bookings")), from_source_alias="colliding_alias", ), from_source_alias="bookings_src", @@ -450,9 +442,7 @@ def colliding_select_statement() -> SqlSelectStatementNode: column_alias="listing", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="dim_listings") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="dim_listings")), from_source_alias="colliding_alias", ), right_source_alias="listings_src", @@ -603,9 +593,7 @@ def reduce_all_join_select_statement() -> SqlSelectStatementNode: column_alias="listing", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="fct_bookings") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="fct_bookings")), from_source_alias="fct_bookings_src", ), from_source_alias="bookings_src", @@ -627,9 +615,7 @@ def reduce_all_join_select_statement() -> SqlSelectStatementNode: column_alias="listing", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="dim_listings") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="dim_listings")), from_source_alias="dim_listings_src1", ), right_source_alias="listings_src1", @@ -661,9 +647,7 @@ def reduce_all_join_select_statement() -> SqlSelectStatementNode: column_alias="listing", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="dim_listings") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="dim_listings")), from_source_alias="dim_listings_src2", ), right_source_alias="listings_src2", @@ -799,9 +783,7 @@ def reducing_join_statement() -> SqlSelectStatementNode: column_alias="bookings", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="fct_bookings") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="fct_bookings")), from_source_alias="src0", ), from_source_alias="src1", @@ -824,9 +806,7 @@ def reducing_join_statement() -> SqlSelectStatementNode: column_alias="listings", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="fct_listings") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="fct_listings")), from_source_alias="src4", ), right_source_alias="src3", @@ -917,9 +897,7 @@ def reducing_join_left_node_statement() -> SqlSelectStatementNode: column_alias="listings", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="fct_listings") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="fct_listings")), from_source_alias="src4", ), from_source_alias="src2", @@ -950,7 +928,7 @@ def reducing_join_left_node_statement() -> SqlSelectStatementNode: column_alias="bookings", ), ), - from_source=SqlTableFromClauseNode.create( + from_source=SqlTableNode.create( sql_table=SqlTable(schema_name="demo", table_name="fct_bookings") ), from_source_alias="src0", @@ -1019,9 +997,7 @@ def test_rewriting_distinct_select_node_is_not_reduced( column_alias="bookings", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="fct_bookings") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="fct_bookings")), from_source_alias="a", distinct=True, ), diff --git a/tests_metricflow/sql/optimizer/test_sub_query_reducer.py b/tests_metricflow/sql/optimizer/test_sub_query_reducer.py index 25e92766f0..30726e8ac4 100644 --- a/tests_metricflow/sql/optimizer/test_sub_query_reducer.py +++ b/tests_metricflow/sql/optimizer/test_sub_query_reducer.py @@ -18,7 +18,7 @@ SqlOrderByDescription, SqlSelectColumn, SqlSelectStatementNode, - SqlTableFromClauseNode, + SqlTableNode, ) from tests_metricflow.sql.compare_sql_plan import assert_default_rendered_sql_equal @@ -100,9 +100,7 @@ def base_select_statement() -> SqlSelectStatementNode: column_alias="col1", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="from_source_table") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="from_source_table")), from_source_alias="src0", limit=2, ), @@ -200,13 +198,11 @@ def rewrite_order_by_statement() -> SqlSelectStatementNode: column_alias="col1", ), ), - from_source=SqlTableFromClauseNode.create(sql_table=SqlTable(schema_name="demo", table_name="src0")), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="src0")), from_source_alias="src0", join_descs=( SqlJoinDescription( - right_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="src1") - ), + right_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="src1")), right_source_alias="src1", on_condition=SqlComparisonExpression.create( left_expr=SqlColumnReferenceExpression.create( @@ -291,9 +287,7 @@ def test_distinct_select_node_is_not_reduced( column_alias="bookings", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="fct_bookings") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="fct_bookings")), from_source_alias="a", distinct=True, ), diff --git a/tests_metricflow/sql/optimizer/test_table_alias_simplifier.py b/tests_metricflow/sql/optimizer/test_table_alias_simplifier.py index f3a40191b5..ae54998bf5 100644 --- a/tests_metricflow/sql/optimizer/test_table_alias_simplifier.py +++ b/tests_metricflow/sql/optimizer/test_table_alias_simplifier.py @@ -18,7 +18,7 @@ SqlJoinDescription, SqlSelectColumn, SqlSelectStatementNode, - SqlTableFromClauseNode, + SqlTableNode, ) from tests_metricflow.sql.compare_sql_plan import assert_default_rendered_sql_equal @@ -91,9 +91,7 @@ def base_select_statement() -> SqlSelectStatementNode: column_alias="join_col", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="from_source_table") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="from_source_table")), from_source_alias="from_source_table", ), from_source_alias="from_source", @@ -121,7 +119,7 @@ def base_select_statement() -> SqlSelectStatementNode: column_alias="join_col", ), ), - from_source=SqlTableFromClauseNode.create( + from_source=SqlTableNode.create( sql_table=SqlTable(schema_name="demo", table_name="joined_source_table") ), from_source_alias="joined_source_table", diff --git a/tests_metricflow/sql/test_engine_specific_rendering.py b/tests_metricflow/sql/test_engine_specific_rendering.py index b47f0027a9..60c5a97cac 100644 --- a/tests_metricflow/sql/test_engine_specific_rendering.py +++ b/tests_metricflow/sql/test_engine_specific_rendering.py @@ -23,7 +23,7 @@ SqlOrderByDescription, SqlSelectColumn, SqlSelectStatementNode, - SqlTableFromClauseNode, + SqlTableNode, ) from tests_metricflow.sql.compare_sql_plan import assert_rendered_sql_equal @@ -46,7 +46,7 @@ def test_cast_to_timestamp( ), ] - from_source = SqlTableFromClauseNode.create(sql_table=SqlTable(schema_name="foo", table_name="bar")) + from_source = SqlTableNode.create(sql_table=SqlTable(schema_name="foo", table_name="bar")) from_source_alias = "a" joins_descs: List[SqlJoinDescription] = [] where = None @@ -84,7 +84,7 @@ def test_generate_uuid( column_alias="uuid", ), ] - from_source = SqlTableFromClauseNode.create(sql_table=SqlTable(schema_name="foo", table_name="bar")) + from_source = SqlTableNode.create(sql_table=SqlTable(schema_name="foo", table_name="bar")) from_source_alias = "a" assert_rendered_sql_equal( @@ -125,7 +125,7 @@ def test_continuous_percentile_expr( ), ] - from_source = SqlTableFromClauseNode.create(sql_table=SqlTable(schema_name="foo", table_name="bar")) + from_source = SqlTableNode.create(sql_table=SqlTable(schema_name="foo", table_name="bar")) from_source_alias = "a" joins_descs: List[SqlJoinDescription] = [] where = None @@ -174,7 +174,7 @@ def test_discrete_percentile_expr( ), ] - from_source = SqlTableFromClauseNode.create(sql_table=SqlTable(schema_name="foo", table_name="bar")) + from_source = SqlTableNode.create(sql_table=SqlTable(schema_name="foo", table_name="bar")) from_source_alias = "a" joins_descs: List[SqlJoinDescription] = [] where = None @@ -223,7 +223,7 @@ def test_approximate_continuous_percentile_expr( ), ] - from_source = SqlTableFromClauseNode.create(sql_table=SqlTable(schema_name="foo", table_name="bar")) + from_source = SqlTableNode.create(sql_table=SqlTable(schema_name="foo", table_name="bar")) from_source_alias = "a" joins_descs: List[SqlJoinDescription] = [] where = None @@ -272,7 +272,7 @@ def test_approximate_discrete_percentile_expr( ), ] - from_source = SqlTableFromClauseNode.create(sql_table=SqlTable(schema_name="foo", table_name="bar")) + from_source = SqlTableNode.create(sql_table=SqlTable(schema_name="foo", table_name="bar")) from_source_alias = "a" joins_descs: List[SqlJoinDescription] = [] where = None diff --git a/tests_metricflow/sql/test_sql_plan_render.py b/tests_metricflow/sql/test_sql_plan_render.py index 3d4c761836..c14d67db50 100644 --- a/tests_metricflow/sql/test_sql_plan_render.py +++ b/tests_metricflow/sql/test_sql_plan_render.py @@ -25,7 +25,7 @@ SqlOrderByDescription, SqlSelectColumn, SqlSelectStatementNode, - SqlTableFromClauseNode, + SqlTableNode, ) from tests_metricflow.sql.compare_sql_plan import assert_rendered_sql_equal @@ -49,7 +49,7 @@ def test_component_rendering( ), ] - from_source = SqlTableFromClauseNode.create(sql_table=SqlTable(schema_name="demo", table_name="fct_bookings")) + from_source = SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="fct_bookings")) from_source = from_source from_source_alias = "a" @@ -109,7 +109,7 @@ def test_component_rendering( # Test single join joins_descs.append( SqlJoinDescription( - right_source=SqlTableFromClauseNode.create(sql_table=SqlTable(schema_name="demo", table_name="dim_users")), + right_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="dim_users")), right_source_alias="b", on_condition=SqlComparisonExpression.create( left_expr=SqlColumnReferenceExpression.create(SqlColumnReference("a", "user_id")), @@ -140,9 +140,7 @@ def test_component_rendering( # Test multiple join joins_descs.append( SqlJoinDescription( - right_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="dim_listings") - ), + right_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="dim_listings")), right_source_alias="c", on_condition=SqlComparisonExpression.create( left_expr=SqlColumnReferenceExpression.create(SqlColumnReference("a", "user_id")), @@ -240,9 +238,7 @@ def test_render_where( # noqa: D103 column_alias="booking_value", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="fct_bookings") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="fct_bookings")), from_source_alias="a", where=SqlComparisonExpression.create( left_expr=SqlColumnReferenceExpression.create( @@ -286,9 +282,7 @@ def test_render_order_by( # noqa: D103 column_alias="bookings", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="fct_bookings") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="fct_bookings")), from_source_alias="a", order_bys=( SqlOrderByDescription( @@ -329,9 +323,7 @@ def test_render_limit( # noqa: D103 column_alias="bookings", ), ), - from_source=SqlTableFromClauseNode.create( - sql_table=SqlTable(schema_name="demo", table_name="fct_bookings") - ), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="fct_bookings")), from_source_alias="a", limit=1, ), @@ -356,7 +348,7 @@ def test_render_create_table_as( # noqa: D103 column_alias="bookings", ), ), - from_source=SqlTableFromClauseNode.create(sql_table=SqlTable(schema_name="demo", table_name="fct_bookings")), + from_source=SqlTableNode.create(sql_table=SqlTable(schema_name="demo", table_name="fct_bookings")), from_source_alias="a", limit=1, )