From a45bbbb6f2fbd117d5d314e34e85afc2b48ad677 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 20 Sep 2023 11:22:25 +0200 Subject: Merging upstream version 18.5.1. Signed-off-by: Daniel Baumann --- tests/test_optimizer.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'tests/test_optimizer.py') diff --git a/tests/test_optimizer.py b/tests/test_optimizer.py index 4415e03..a40f089 100644 --- a/tests/test_optimizer.py +++ b/tests/test_optimizer.py @@ -223,12 +223,12 @@ class TestOptimizer(unittest.TestCase): self.assertEqual( optimizer.qualify.qualify( parse_one( - "WITH X AS (SELECT Y.A FROM DB.Y CROSS JOIN a.b.INFORMATION_SCHEMA.COLUMNS) SELECT `A` FROM X", + "WITH X AS (SELECT Y.A FROM DB.y CROSS JOIN a.b.INFORMATION_SCHEMA.COLUMNS) SELECT `A` FROM X", read="bigquery", ), dialect="bigquery", ).sql(), - 'WITH "x" AS (SELECT "y"."a" AS "a" FROM "DB"."Y" AS "y" CROSS JOIN "a"."b"."INFORMATION_SCHEMA"."COLUMNS" AS "columns") SELECT "x"."a" AS "a" FROM "x"', + 'WITH "x" AS (SELECT "y"."a" AS "a" FROM "DB"."y" AS "y" CROSS JOIN "a"."b"."INFORMATION_SCHEMA"."COLUMNS" AS "COLUMNS") SELECT "x"."a" AS "a" FROM "x"', ) self.assertEqual( @@ -776,6 +776,13 @@ 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") + def test_user_defined_type_annotation(self): + schema = MappingSchema({"t": {"x": "int"}}, dialect="postgres") + expression = annotate_types(parse_one("SELECT CAST(x AS IPADDRESS) FROM t"), schema=schema) + + self.assertEqual(exp.DataType.Type.USERDEFINED, expression.selects[0].type.this) + self.assertEqual(expression.selects[0].type.sql(dialect="postgres"), "IPADDRESS") + def test_recursive_cte(self): query = parse_one( """ -- cgit v1.2.3