summaryrefslogtreecommitdiffstats
path: root/tests/test_optimizer.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-10-16 11:37:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-10-16 11:37:35 +0000
commit45eab59f38aae326a4970767f9bc7119bef339b9 (patch)
treef5a21c1bba9fd891c923cc14206986691931ca47 /tests/test_optimizer.py
parentAdding upstream version 18.11.6. (diff)
downloadsqlglot-45eab59f38aae326a4970767f9bc7119bef339b9.tar.xz
sqlglot-45eab59f38aae326a4970767f9bc7119bef339b9.zip
Adding upstream version 18.13.0.upstream/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))