diff options
Diffstat (limited to '')
-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( """ |