diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-05-10 06:44:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-05-10 06:44:58 +0000 |
commit | beba715b97dd2349e01dde9b077d2535680ebdca (patch) | |
tree | 0c54accb48c28eb54d2f48f88d149492717b30e5 /tests/test_optimizer.py | |
parent | Releasing debian version 11.7.1-1. (diff) | |
download | sqlglot-beba715b97dd2349e01dde9b077d2535680ebdca.tar.xz sqlglot-beba715b97dd2349e01dde9b077d2535680ebdca.zip |
Merging upstream version 12.2.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_optimizer.py')
-rw-r--r-- | tests/test_optimizer.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_optimizer.py b/tests/test_optimizer.py index d077570..423cb84 100644 --- a/tests/test_optimizer.py +++ b/tests/test_optimizer.py @@ -47,6 +47,7 @@ class TestOptimizer(unittest.TestCase): @classmethod def setUpClass(cls): + sqlglot.schema = MappingSchema() cls.conn = duckdb.connect() cls.conn.execute( """ @@ -221,6 +222,12 @@ class TestOptimizer(unittest.TestCase): self.check_file("pushdown_predicates", optimizer.pushdown_predicates.pushdown_predicates) def test_expand_laterals(self): + # check order of lateral expansion with no schema + self.assertEqual( + optimizer.optimize("SELECT a + 1 AS d, d + 1 AS e FROM x " "").sql(), + 'SELECT "x"."a" + 1 AS "d", "x"."a" + 2 AS "e" FROM "x" AS "x"', + ) + self.check_file( "expand_laterals", optimizer.expand_laterals.expand_laterals, @@ -612,6 +619,12 @@ FROM READ_CSV('tests/fixtures/optimizer/tpc-h/nation.csv.gz', 'delimiter', '|') expression = annotate_types(parse_one("CONCAT('A', 'B')")) self.assertEqual(expression.type.this, exp.DataType.Type.VARCHAR) + def test_root_subquery_annotation(self): + expression = annotate_types(parse_one("(SELECT 1, 2 FROM x) LIMIT 0")) + self.assertIsInstance(expression, exp.Subquery) + self.assertEqual(exp.DataType.Type.INT, expression.selects[0].type.this) + self.assertEqual(exp.DataType.Type.INT, expression.selects[1].type.this) + def test_recursive_cte(self): query = parse_one( """ |