diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-05-10 06:44:54 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-05-10 06:44:54 +0000 |
commit | d2e9401b18925b5702c5c758af7d4f5b61deb493 (patch) | |
tree | 58dbf490c0457c2908751b3e4b63af13287381ee /tests/test_optimizer.py | |
parent | Adding upstream version 11.7.1. (diff) | |
download | sqlglot-d2e9401b18925b5702c5c758af7d4f5b61deb493.tar.xz sqlglot-d2e9401b18925b5702c5c758af7d4f5b61deb493.zip |
Adding upstream version 12.2.0.upstream/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( """ |