From 341eb1a6bdf0dd5b015e5140d3b068c6fd3f4d87 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 7 Sep 2023 13:39:43 +0200 Subject: Adding upstream version 18.2.0. Signed-off-by: Daniel Baumann --- tests/test_optimizer.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/test_optimizer.py') 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") + + 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") + def test_recursive_cte(self): query = parse_one( """ -- cgit v1.2.3