summaryrefslogtreecommitdiffstats
path: root/tests/test_optimizer.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-12 10:06:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-12 10:06:28 +0000
commit918abde014f9e5c75dfbe21110c379f7f70435c9 (patch)
tree3419a01e34958bffbd917fa9e600eda126ea3a87 /tests/test_optimizer.py
parentReleasing debian version 10.6.3-1. (diff)
downloadsqlglot-918abde014f9e5c75dfbe21110c379f7f70435c9.tar.xz
sqlglot-918abde014f9e5c75dfbe21110c379f7f70435c9.zip
Merging upstream version 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.py19
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 = """