From d2e9401b18925b5702c5c758af7d4f5b61deb493 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 May 2023 08:44:54 +0200 Subject: Adding upstream version 12.2.0. Signed-off-by: Daniel Baumann --- tests/test_optimizer.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/test_optimizer.py') 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( """ -- cgit v1.2.3