summaryrefslogtreecommitdiffstats
path: root/tests/test_optimizer.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-04 07:24:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-04 07:24:05 +0000
commit621555af37594a213d91ea113d5fc7739af84d40 (patch)
tree5aaa3b586692062accffc21cfaaa5a3917ee77b3 /tests/test_optimizer.py
parentAdding upstream version 10.2.9. (diff)
downloadsqlglot-621555af37594a213d91ea113d5fc7739af84d40.tar.xz
sqlglot-621555af37594a213d91ea113d5fc7739af84d40.zip
Adding upstream version 10.4.2.upstream/10.4.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_optimizer.py')
-rw-r--r--tests/test_optimizer.py29
1 files changed, 26 insertions, 3 deletions
diff --git a/tests/test_optimizer.py b/tests/test_optimizer.py
index 0c5f6cd..1c97be7 100644
--- a/tests/test_optimizer.py
+++ b/tests/test_optimizer.py
@@ -164,9 +164,6 @@ class TestOptimizer(unittest.TestCase):
with self.assertRaises(OptimizeError):
optimizer.qualify_columns.qualify_columns(parse_one(sql), schema=self.schema)
- def test_quote_identities(self):
- self.check_file("quote_identities", optimizer.quote_identities.quote_identities)
-
def test_lower_identities(self):
self.check_file("lower_identities", optimizer.lower_identities.lower_identities)
@@ -555,3 +552,29 @@ FROM READ_CSV('tests/fixtures/optimizer/tpc-h/nation.csv.gz', 'delimiter', '|')
parse_one(f"SELECT {func}(x.{col}) AS _col_0 FROM x AS x"), schema=schema
)
self.assertEqual(expression.expressions[0].type.this, target_type)
+
+ def test_recursive_cte(self):
+ query = parse_one(
+ """
+ with recursive t(n) AS
+ (
+ select 1
+ union all
+ select n + 1
+ FROM t
+ where n < 3
+ ), y AS (
+ select n
+ FROM t
+ union all
+ select n + 1
+ FROM y
+ where n < 2
+ )
+ select * from y
+ """
+ )
+
+ scope_t, scope_y = build_scope(query).cte_scopes
+ self.assertEqual(set(scope_t.cte_sources), {"t"})
+ self.assertEqual(set(scope_y.cte_sources), {"t", "y"})