Skip to content

Commit

Permalink
Update snapshots.
Browse files Browse the repository at this point in the history
  • Loading branch information
plypaul committed Nov 10, 2024
1 parent b8be5b2 commit 8a97d26
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8a97d26

Please sign in to comment.