Skip to content

Commit

Permalink
Update snapshots.
Browse files Browse the repository at this point in the history
  • Loading branch information
plypaul committed Nov 11, 2024
1 parent 2534570 commit 2379116
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 2379116

Please sign in to comment.