diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-12 10:03:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-12 10:03:37 +0000 |
commit | 24e839c04c39d1f4423b267c371e8e5b5bc33867 (patch) | |
tree | 2395ec71424fe1ff783e0dc7ca0f9b4e16def8a9 /tests/test_optimizer.py | |
parent | Adding upstream version 10.6.3. (diff) | |
download | sqlglot-24e839c04c39d1f4423b267c371e8e5b5bc33867.tar.xz sqlglot-24e839c04c39d1f4423b267c371e8e5b5bc33867.zip |
Adding upstream version 11.0.1.upstream/11.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_optimizer.py')
-rw-r--r-- | tests/test_optimizer.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/test_optimizer.py b/tests/test_optimizer.py index 360dfb5..b6993ba 100644 --- a/tests/test_optimizer.py +++ b/tests/test_optimizer.py @@ -163,7 +163,10 @@ class TestOptimizer(unittest.TestCase): for sql in load_sql_fixtures("optimizer/qualify_columns__invalid.sql"): with self.subTest(sql): with self.assertRaises((OptimizeError, SchemaError)): - optimizer.qualify_columns.qualify_columns(parse_one(sql), schema=self.schema) + expression = optimizer.qualify_columns.qualify_columns( + parse_one(sql), schema=self.schema + ) + optimizer.qualify_columns.validate_qualify_columns(expression) def test_lower_identities(self): self.check_file("lower_identities", optimizer.lower_identities.lower_identities) @@ -190,6 +193,14 @@ class TestOptimizer(unittest.TestCase): def test_pushdown_predicates(self): self.check_file("pushdown_predicates", optimizer.pushdown_predicates.pushdown_predicates) + def test_expand_laterals(self): + self.check_file( + "expand_laterals", + optimizer.expand_laterals.expand_laterals, + pretty=True, + execute=True, + ) + def test_expand_multi_table_selects(self): self.check_file( "expand_multi_table_selects", @@ -369,6 +380,12 @@ FROM READ_CSV('tests/fixtures/optimizer/tpc-h/nation.csv.gz', 'delimiter', '|') self.assertEqual(expression.right.this.left.type.this, exp.DataType.Type.INT) self.assertEqual(expression.right.this.right.type.this, exp.DataType.Type.INT) + def test_lateral_annotation(self): + expression = optimizer.optimize( + parse_one("SELECT c FROM (select 1 a) as x LATERAL VIEW EXPLODE (a) AS c") + ).expressions[0] + self.assertEqual(expression.type.this, exp.DataType.Type.INT) + def test_derived_tables_column_annotation(self): schema = {"x": {"cola": "INT"}, "y": {"cola": "FLOAT"}} sql = """ |