summaryrefslogtreecommitdiffstats
path: root/tests/test_optimizer.py
diff options
context:
space:
mode:
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))