summaryrefslogtreecommitdiffstats
path: root/tests/test_optimizer.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-20 09:22:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-20 09:22:22 +0000
commit281115ae80458761fb3593c81fe9488976b87c6d (patch)
treef159075e865f3bad227b365878dc315eeab64112 /tests/test_optimizer.py
parentAdding upstream version 18.4.1. (diff)
downloadsqlglot-281115ae80458761fb3593c81fe9488976b87c6d.tar.xz
sqlglot-281115ae80458761fb3593c81fe9488976b87c6d.zip
Adding upstream version 18.5.1.upstream/18.5.1
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, 9 insertions, 2 deletions
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<INT>")
+ 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(
"""