From 8a97d26e60dc6e04ae64b4f16b381ef7383245bf Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Sat, 9 Nov 2024 16:20:55 -0800 Subject: [PATCH] Update snapshots. --- .../str/test_multi_child_pruning__result.txt | 55 +++++++++++++++++++ .../str/test_nested_pruning__result.txt | 49 +++++++++++++++++ .../str/test_no_pruning__result.txt | 33 +++++++++++ .../str/test_simple_pruning__result.txt | 34 ++++++++++++ 4 files changed, 171 insertions(+) create mode 100644 tests_metricflow/snapshots/test_cte_column_pruner.py/str/test_multi_child_pruning__result.txt create mode 100644 tests_metricflow/snapshots/test_cte_column_pruner.py/str/test_nested_pruning__result.txt create mode 100644 tests_metricflow/snapshots/test_cte_column_pruner.py/str/test_no_pruning__result.txt create mode 100644 tests_metricflow/snapshots/test_cte_column_pruner.py/str/test_simple_pruning__result.txt diff --git a/tests_metricflow/snapshots/test_cte_column_pruner.py/str/test_multi_child_pruning__result.txt b/tests_metricflow/snapshots/test_cte_column_pruner.py/str/test_multi_child_pruning__result.txt new file mode 100644 index 000000000..06afad57f --- /dev/null +++ b/tests_metricflow/snapshots/test_cte_column_pruner.py/str/test_multi_child_pruning__result.txt @@ -0,0 +1,55 @@ +test_name: test_multi_child_pruning +test_filename: test_cte_column_pruner.py +docstring: + Tests the case of pruning a CTE where difference sources depend on the same CTE. +--- +optimizer: + SqlColumnPrunerOptimizer + +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 + , test_table_alias.col_1 AS cte_source_0__col_2 + FROM test_schema.test_table test_table_alias + ) + + 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 ( + -- Joined sub-query + SELECT + cte_source_0_alias_in_right_source.cte_source_0__col_0 AS right_source__col_0 + , cte_source_0_alias_in_right_source.cte_source_0__col_1 AS right_source__col_1 + FROM cte_source_0 cte_source_0_alias_in_right_source + ) right_source_alias + ON + cte_source_0_alias.cte_source_0__col_1 = right_source_alias.right_source__col_1 + +sql_after_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 test_schema.test_table test_table_alias + ) + + 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 ( + -- Joined sub-query + SELECT + cte_source_0_alias_in_right_source.cte_source_0__col_1 AS right_source__col_1 + FROM cte_source_0 cte_source_0_alias_in_right_source + ) right_source_alias + ON + cte_source_0_alias.cte_source_0__col_1 = right_source_alias.right_source__col_1 diff --git a/tests_metricflow/snapshots/test_cte_column_pruner.py/str/test_nested_pruning__result.txt b/tests_metricflow/snapshots/test_cte_column_pruner.py/str/test_nested_pruning__result.txt new file mode 100644 index 000000000..eaffc3754 --- /dev/null +++ b/tests_metricflow/snapshots/test_cte_column_pruner.py/str/test_nested_pruning__result.txt @@ -0,0 +1,49 @@ +test_name: test_nested_pruning +test_filename: test_cte_column_pruner.py +docstring: + Tests the case of pruning a CTE where a query depends on a CTE, and that CTE depends on another CTE. +--- +optimizer: + SqlColumnPrunerOptimizer + +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 test_schema.test_table test_table_alias + ) + + , cte_source_1 AS ( + -- CTE source 1 + SELECT + cte_source_0_alias.cte_source_0__col_0 AS cte_source_1__col_0 + , cte_source_0_alias.cte_source_0__col_0 AS cte_source_1__col_1 + FROM cte_source_0 cte_source_0_alias + ) + + SELECT + cte_source_1_alias.cte_source_1__col_0 AS top_level__col_0 + FROM cte_source_1 cte_source_1_alias + +sql_after_optimizing: + -- Top-level SELECT + WITH cte_source_0 AS ( + -- CTE source 0 + SELECT + test_table_alias.col_0 AS cte_source_0__col_0 + FROM test_schema.test_table test_table_alias + ) + + , cte_source_1 AS ( + -- CTE source 1 + SELECT + cte_source_0_alias.cte_source_0__col_0 AS cte_source_1__col_0 + FROM cte_source_0 cte_source_0_alias + ) + + SELECT + cte_source_1_alias.cte_source_1__col_0 AS top_level__col_0 + FROM cte_source_1 cte_source_1_alias diff --git a/tests_metricflow/snapshots/test_cte_column_pruner.py/str/test_no_pruning__result.txt b/tests_metricflow/snapshots/test_cte_column_pruner.py/str/test_no_pruning__result.txt new file mode 100644 index 000000000..c0b8df87b --- /dev/null +++ b/tests_metricflow/snapshots/test_cte_column_pruner.py/str/test_no_pruning__result.txt @@ -0,0 +1,33 @@ +test_name: test_no_pruning +test_filename: test_cte_column_pruner.py +docstring: + Tests a case where no pruning should occur for a CTE. +--- +optimizer: + SqlColumnPrunerOptimizer + +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 + FROM test_schema.test_table test_table_alias + ) + + SELECT + cte_source_0_alias.cte_source_0__col_0 AS top_level__col_0 + FROM cte_source_0 cte_source_0_alias + +sql_after_optimizing: + -- Top-level SELECT + WITH cte_source_0 AS ( + -- CTE source 0 + SELECT + test_table_alias.col_0 AS cte_source_0__col_0 + FROM test_schema.test_table test_table_alias + ) + + SELECT + cte_source_0_alias.cte_source_0__col_0 AS top_level__col_0 + FROM cte_source_0 cte_source_0_alias diff --git a/tests_metricflow/snapshots/test_cte_column_pruner.py/str/test_simple_pruning__result.txt b/tests_metricflow/snapshots/test_cte_column_pruner.py/str/test_simple_pruning__result.txt new file mode 100644 index 000000000..b87aebe7e --- /dev/null +++ b/tests_metricflow/snapshots/test_cte_column_pruner.py/str/test_simple_pruning__result.txt @@ -0,0 +1,34 @@ +test_name: test_simple_pruning +test_filename: test_cte_column_pruner.py +docstring: + Tests the simplest case of pruning a CTE where a query depends on a CTE, and that CTE is pruned. +--- +optimizer: + SqlColumnPrunerOptimizer + +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_0 AS cte_source_0__col_1 + FROM test_schema.test_table test_table_alias + ) + + SELECT + cte_source_0_alias.cte_source_0__col_0 AS top_level__col_0 + FROM cte_source_0 cte_source_0_alias + +sql_after_optimizing: + -- Top-level SELECT + WITH cte_source_0 AS ( + -- CTE source 0 + SELECT + test_table_alias.col_0 AS cte_source_0__col_0 + FROM test_schema.test_table test_table_alias + ) + + SELECT + cte_source_0_alias.cte_source_0__col_0 AS top_level__col_0 + FROM cte_source_0 cte_source_0_alias