From d09b3fa83b534916ff551ad815ad2167f52211fb Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Sat, 9 Nov 2024 16:27:16 -0800 Subject: [PATCH] Update snapshots. --- ...est_table_alias_simplification__result.txt | 91 +++++++++++++++++++ ...lification__after_alias_simplification.sql | 2 +- ...ification__before_alias_simplification.sql | 2 +- 3 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 tests_metricflow/snapshots/test_cte_table_alias_simplifier.py/str/test_table_alias_simplification__result.txt diff --git a/tests_metricflow/snapshots/test_cte_table_alias_simplifier.py/str/test_table_alias_simplification__result.txt b/tests_metricflow/snapshots/test_cte_table_alias_simplifier.py/str/test_table_alias_simplification__result.txt new file mode 100644 index 000000000..35008eef8 --- /dev/null +++ b/tests_metricflow/snapshots/test_cte_table_alias_simplifier.py/str/test_table_alias_simplification__result.txt @@ -0,0 +1,91 @@ +test_name: test_table_alias_simplification +test_filename: test_cte_table_alias_simplifier.py +docstring: + Tests that table aliases are removed when not needed in CTEs. +--- +optimizer: + SqlTableAliasSimplifier + +sql_before_optimizing: + -- Top-level SELECT + WITH cte_source_0 AS ( + -- CTE source 0 + SELECT + test_table_alias.col_0 AS cte_source_0__col_0 + , test_table_alias.col_1 AS cte_source_0__col_1 + FROM ( + -- CTE source 0 sub-query + SELECT + test_table_alias.col_0 AS cte_source_0_subquery__col_0 + , test_table_alias.col_0 AS cte_source_0_subquery__col_1 + FROM test_schema.test_table test_table_alias + ) cte_source_0_subquery + ) + + , cte_source_1 AS ( + -- CTE source 1 + SELECT + test_table_alias.col_0 AS cte_source_1__col_0 + , test_table_alias.col_1 AS cte_source_1__col_1 + FROM ( + -- CTE source 1 sub-query + SELECT + cte_source_0_alias.cte_source_0__col_0 AS cte_source_1_subquery__col_0 + , cte_source_0_alias.cte_source_0__col_0 AS cte_source_1_subquery__col_1 + FROM cte_source_0 cte_source_0_alias + ) cte_source_1_subquery + ) + + SELECT + cte_source_0_alias.cte_source_0__col_0 AS top_level__col_0 + , right_source_alias.right_source__col_1 AS top_level__col_1 + FROM cte_source_0 cte_source_0_alias + INNER JOIN + cte_source_1 right_source_alias + ON + cte_source_0_alias.cte_source_0__col_1 = right_source_alias.right_source__col_1 + GROUP BY + cte_source_0_alias.cte_source_0__col_0 + , right_source_alias.right_source__col_1 + +sql_after_optimizing: + -- Top-level SELECT + WITH cte_source_0 AS ( + -- CTE source 0 + SELECT + col_0 AS cte_source_0__col_0 + , col_1 AS cte_source_0__col_1 + FROM ( + -- CTE source 0 sub-query + SELECT + col_0 AS cte_source_0_subquery__col_0 + , col_0 AS cte_source_0_subquery__col_1 + FROM test_schema.test_table test_table_alias + ) cte_source_0_subquery + ) + + , cte_source_1 AS ( + -- CTE source 1 + SELECT + col_0 AS cte_source_1__col_0 + , col_1 AS cte_source_1__col_1 + FROM ( + -- CTE source 1 sub-query + SELECT + cte_source_0__col_0 AS cte_source_1_subquery__col_0 + , cte_source_0__col_0 AS cte_source_1_subquery__col_1 + FROM cte_source_0 cte_source_0_alias + ) cte_source_1_subquery + ) + + SELECT + cte_source_0_alias.cte_source_0__col_0 AS top_level__col_0 + , right_source_alias.right_source__col_1 AS top_level__col_1 + FROM cte_source_0 cte_source_0_alias + INNER JOIN + cte_source_1 right_source_alias + ON + cte_source_0_alias.cte_source_0__col_1 = right_source_alias.right_source__col_1 + GROUP BY + cte_source_0_alias.cte_source_0__col_0 + , right_source_alias.right_source__col_1 diff --git a/tests_metricflow/snapshots/test_table_alias_simplifier.py/SqlQueryPlan/test_table_alias_simplification__after_alias_simplification.sql b/tests_metricflow/snapshots/test_table_alias_simplifier.py/SqlQueryPlan/test_table_alias_simplification__after_alias_simplification.sql index ef3a220e2..c6dc990b8 100644 --- a/tests_metricflow/snapshots/test_table_alias_simplifier.py/SqlQueryPlan/test_table_alias_simplification__after_alias_simplification.sql +++ b/tests_metricflow/snapshots/test_table_alias_simplifier.py/SqlQueryPlan/test_table_alias_simplification__after_alias_simplification.sql @@ -1,7 +1,7 @@ test_name: test_table_alias_simplification test_filename: test_table_alias_simplifier.py docstring: - Tests a case where no pruning should occur. + Tests that table aliases are removed when not needed. --- -- test0 SELECT diff --git a/tests_metricflow/snapshots/test_table_alias_simplifier.py/SqlQueryPlan/test_table_alias_simplification__before_alias_simplification.sql b/tests_metricflow/snapshots/test_table_alias_simplifier.py/SqlQueryPlan/test_table_alias_simplification__before_alias_simplification.sql index c7fcac1e8..307de0c52 100644 --- a/tests_metricflow/snapshots/test_table_alias_simplifier.py/SqlQueryPlan/test_table_alias_simplification__before_alias_simplification.sql +++ b/tests_metricflow/snapshots/test_table_alias_simplifier.py/SqlQueryPlan/test_table_alias_simplification__before_alias_simplification.sql @@ -1,7 +1,7 @@ test_name: test_table_alias_simplification test_filename: test_table_alias_simplifier.py docstring: - Tests a case where no pruning should occur. + Tests that table aliases are removed when not needed. --- -- test0 SELECT