From 3742f86d166160ca3843872ebecb6f30c51f6085 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 14 Aug 2023 12:12:19 +0200 Subject: Merging upstream version 17.12.0. Signed-off-by: Daniel Baumann --- tests/dialects/test_presto.py | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'tests/dialects/test_presto.py') diff --git a/tests/dialects/test_presto.py b/tests/dialects/test_presto.py index ec1ad30..5091540 100644 --- a/tests/dialects/test_presto.py +++ b/tests/dialects/test_presto.py @@ -1,6 +1,6 @@ from unittest import mock -from sqlglot import UnsupportedError +from sqlglot import UnsupportedError, exp, parse_one from tests.dialects.test_dialect import Validator @@ -8,6 +8,23 @@ class TestPresto(Validator): dialect = "presto" def test_cast(self): + self.validate_identity("CAST(x AS IPADDRESS)") + self.validate_identity("CAST(x AS IPPREFIX)") + + self.validate_all( + "CAST(x AS INTERVAL YEAR TO MONTH)", + write={ + "oracle": "CAST(x AS INTERVAL YEAR TO MONTH)", + "presto": "CAST(x AS INTERVAL YEAR TO MONTH)", + }, + ) + self.validate_all( + "CAST(x AS INTERVAL DAY TO SECOND)", + write={ + "oracle": "CAST(x AS INTERVAL DAY TO SECOND)", + "presto": "CAST(x AS INTERVAL DAY TO SECOND)", + }, + ) self.validate_all( "SELECT CAST('10C' AS INTEGER)", read={ @@ -99,18 +116,25 @@ class TestPresto(Validator): "snowflake": "CAST(OBJECT_CONSTRUCT('a', [1], 'b', [2], 'c', [3]) AS OBJECT)", }, ) + self.validate_all( + "CAST(x AS TIME(5) WITH TIME ZONE)", + write={ + "duckdb": "CAST(x AS TIMETZ)", + "postgres": "CAST(x AS TIMETZ(5))", + "presto": "CAST(x AS TIME(5) WITH TIME ZONE)", + "redshift": "CAST(x AS TIME(5) WITH TIME ZONE)", + }, + ) self.validate_all( "CAST(x AS TIMESTAMP(9) WITH TIME ZONE)", write={ "bigquery": "CAST(x AS TIMESTAMP)", - "duckdb": "CAST(x AS TIMESTAMPTZ(9))", + "duckdb": "CAST(x AS TIMESTAMPTZ)", "presto": "CAST(x AS TIMESTAMP(9) WITH TIME ZONE)", "hive": "CAST(x AS TIMESTAMP)", "spark": "CAST(x AS TIMESTAMP)", }, ) - self.validate_identity("CAST(x AS IPADDRESS)") - self.validate_identity("CAST(x AS IPPREFIX)") def test_regex(self): self.validate_all( @@ -179,6 +203,9 @@ class TestPresto(Validator): ) def test_time(self): + expr = parse_one("TIME(7) WITH TIME ZONE", into=exp.DataType, read="presto") + self.assertEqual(expr.this, exp.DataType.Type.TIMETZ) + self.validate_identity("FROM_UNIXTIME(a, b)") self.validate_identity("FROM_UNIXTIME(a, b, c)") self.validate_identity("TRIM(a, b)") -- cgit v1.2.3