diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-11 12:46:06 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-11 12:46:06 +0000 |
commit | 9dae42c19381cf27dc56bd932aebd780aa66722b (patch) | |
tree | d70521fc9bf401e225f567a2d6acf1c1e4add2fd /tests/dialects/test_presto.py | |
parent | Adding upstream version 15.0.0. (diff) | |
download | sqlglot-upstream/15.2.0.tar.xz sqlglot-upstream/15.2.0.zip |
Adding upstream version 15.2.0.upstream/15.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/dialects/test_presto.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/dialects/test_presto.py b/tests/dialects/test_presto.py index 1f5953c..e3d09ef 100644 --- a/tests/dialects/test_presto.py +++ b/tests/dialects/test_presto.py @@ -7,6 +7,18 @@ class TestPresto(Validator): def test_cast(self): self.validate_all( + "SELECT DATE_DIFF('week', CAST(SUBSTR(CAST('2009-01-01' AS VARCHAR), 1, 10) AS DATE), CAST(SUBSTR(CAST('2009-12-31' AS VARCHAR), 1, 10) AS DATE))", + read={"redshift": "SELECT DATEDIFF(week, '2009-01-01', '2009-12-31')"}, + ) + self.validate_all( + "SELECT DATE_ADD('month', 18, CAST(SUBSTR(CAST('2008-02-28' AS VARCHAR), 1, 10) AS DATE))", + read={"redshift": "SELECT DATEADD(month, 18, '2008-02-28')"}, + ) + self.validate_all( + "SELECT TRY_CAST('1970-01-01 00:00:00' AS TIMESTAMP)", + read={"postgres": "SELECT 'epoch'::TIMESTAMP"}, + ) + self.validate_all( "FROM_BASE64(x)", read={ "hive": "UNBASE64(x)", @@ -434,10 +446,17 @@ class TestPresto(Validator): self.validate_identity("START TRANSACTION ISOLATION LEVEL REPEATABLE READ") self.validate_identity("APPROX_PERCENTILE(a, b, c, d)") + self.validate_all("VALUES 1, 2, 3", write={"presto": "VALUES (1), (2), (3)"}) self.validate_all("INTERVAL '1 day'", write={"trino": "INTERVAL '1' day"}) self.validate_all("(5 * INTERVAL '7' day)", read={"": "INTERVAL '5' week"}) self.validate_all("(5 * INTERVAL '7' day)", read={"": "INTERVAL '5' WEEKS"}) self.validate_all( + "SELECT SUBSTRING(a, 1, 3), SUBSTRING(a, LENGTH(a) - (3 - 1))", + read={ + "redshift": "SELECT LEFT(a, 3), RIGHT(a, 3)", + }, + ) + self.validate_all( "WITH RECURSIVE t(n) AS (SELECT 1 AS n UNION ALL SELECT n + 1 AS n FROM t WHERE n < 4) SELECT SUM(n) FROM t", read={ "postgres": "WITH RECURSIVE t AS (SELECT 1 AS n UNION ALL SELECT n + 1 AS n FROM t WHERE n < 4) SELECT SUM(n) FROM t", |