summaryrefslogtreecommitdiffstats
path: root/tests/test_optimizer.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-10-16 11:37:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-10-16 11:37:39 +0000
commitf10d022e11dcd1015db1a74ce9f4198ebdcb7f40 (patch)
treeac7bdc1d214a0f97f991cff14e933f4895ee68e1 /tests/test_optimizer.py
parentReleasing progress-linux version 18.11.6-1. (diff)
downloadsqlglot-f10d022e11dcd1015db1a74ce9f4198ebdcb7f40.tar.xz
sqlglot-f10d022e11dcd1015db1a74ce9f4198ebdcb7f40.zip
Merging upstream version 18.13.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_optimizer.py')
-rw-r--r--tests/test_optimizer.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/test_optimizer.py b/tests/test_optimizer.py
index 8fc3273..c43a84e 100644
--- a/tests/test_optimizer.py
+++ b/tests/test_optimizer.py
@@ -45,6 +45,10 @@ def normalize(expression, **kwargs):
return optimizer.simplify.simplify(expression)
+def simplify(expression, **kwargs):
+ return optimizer.simplify.simplify(expression, constant_propagation=True, **kwargs)
+
+
class TestOptimizer(unittest.TestCase):
maxDiff = None
@@ -271,7 +275,7 @@ class TestOptimizer(unittest.TestCase):
self.check_file("pushdown_projections", pushdown_projections, schema=self.schema)
def test_simplify(self):
- self.check_file("simplify", optimizer.simplify.simplify)
+ self.check_file("simplify", simplify)
expression = parse_one("TRUE AND TRUE AND TRUE")
self.assertEqual(exp.true(), optimizer.simplify.simplify(expression))
@@ -823,6 +827,11 @@ FROM READ_CSV('tests/fixtures/optimizer/tpc-h/nation.csv.gz', 'delimiter', '|')
self.assertEqual(exp.DataType.Type.ARRAY, expression.selects[0].type.this)
self.assertEqual(expression.selects[0].type.sql(), "ARRAY<INT>")
+ schema = MappingSchema({"t": {"c": "STRUCT<`f` STRING>"}}, dialect="bigquery")
+ expression = annotate_types(parse_one("SELECT t.c FROM t"), schema=schema)
+
+ self.assertEqual(expression.selects[0].type.sql(dialect="bigquery"), "STRUCT<`f` STRING>")
+
def test_type_annotation_cache(self):
sql = "SELECT 1 + 1"
expression = annotate_types(parse_one(sql))