-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
...s_metricflow/snapshots/test_cte_column_pruner.py/str/test_multi_child_pruning__result.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
49 changes: 49 additions & 0 deletions
49
tests_metricflow/snapshots/test_cte_column_pruner.py/str/test_nested_pruning__result.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
33 changes: 33 additions & 0 deletions
33
tests_metricflow/snapshots/test_cte_column_pruner.py/str/test_no_pruning__result.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
34 changes: 34 additions & 0 deletions
34
tests_metricflow/snapshots/test_cte_column_pruner.py/str/test_simple_pruning__result.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |