summaryrefslogtreecommitdiffstats
path: root/tests/test_optimizer.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-07 11:39:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-07 11:39:43 +0000
commit341eb1a6bdf0dd5b015e5140d3b068c6fd3f4d87 (patch)
tree61fb7eca2238fb5d41d3906f4af41de03abd25ea /tests/test_optimizer.py
parentAdding upstream version 17.12.0. (diff)
downloadsqlglot-341eb1a6bdf0dd5b015e5140d3b068c6fd3f4d87.tar.xz
sqlglot-341eb1a6bdf0dd5b015e5140d3b068c6fd3f4d87.zip
Adding upstream version 18.2.0.upstream/18.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_optimizer.py')
-rw-r--r--tests/test_optimizer.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_optimizer.py b/tests/test_optimizer.py
index a1bd309..e001c1f 100644
--- a/tests/test_optimizer.py
+++ b/tests/test_optimizer.py
@@ -758,6 +758,24 @@ FROM READ_CSV('tests/fixtures/optimizer/tpc-h/nation.csv.gz', 'delimiter', '|')
self.assertEqual(exp.DataType.Type.INT, expression.selects[0].type.this)
self.assertEqual(exp.DataType.Type.INT, expression.selects[1].type.this)
+ def test_nested_type_annotation(self):
+ schema = {"order": {"customer_id": "bigint", "item_id": "bigint", "item_price": "numeric"}}
+ sql = """
+ SELECT ARRAY_AGG(DISTINCT order.item_id) FILTER (WHERE order.item_price > 10) AS items,
+ FROM order AS order
+ GROUP BY order.customer_id
+ """
+ expression = annotate_types(parse_one(sql), schema=schema)
+
+ self.assertEqual(exp.DataType.Type.ARRAY, expression.selects[0].type.this)
+ self.assertEqual(expression.selects[0].type.sql(), "ARRAY<BIGINT>")
+
+ expression = annotate_types(
+ parse_one("SELECT ARRAY_CAT(ARRAY[1,2,3], ARRAY[4,5])", read="postgres")
+ )
+ self.assertEqual(exp.DataType.Type.ARRAY, expression.selects[0].type.this)
+ self.assertEqual(expression.selects[0].type.sql(), "ARRAY<INT>")
+
def test_recursive_cte(self):
query = parse_one(
"""