Adding upstream version 17.12.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
276276930e
commit
9de781a59b
64 changed files with 12465 additions and 11885 deletions
|
@ -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)")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue