summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_presto.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-14 10:12:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-14 10:12:13 +0000
commitcdffd0b29d5b072639bb02118d6828f4d1b76099 (patch)
tree57ec0b75c40e40a33060b63599bbba6f0af27ae8 /tests/dialects/test_presto.py
parentAdding upstream version 17.11.0. (diff)
downloadsqlglot-cdffd0b29d5b072639bb02118d6828f4d1b76099.tar.xz
sqlglot-cdffd0b29d5b072639bb02118d6828f4d1b76099.zip
Adding upstream version 17.12.0.upstream/17.12.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_presto.py')
-rw-r--r--tests/dialects/test_presto.py35
1 files changed, 31 insertions, 4 deletions
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={
@@ -100,17 +117,24 @@ class TestPresto(Validator):
},
)
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)")