summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_presto.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dialects/test_presto.py')
-rw-r--r--tests/dialects/test_presto.py36
1 files changed, 24 insertions, 12 deletions
diff --git a/tests/dialects/test_presto.py b/tests/dialects/test_presto.py
index 8b5080c..387b0e0 100644
--- a/tests/dialects/test_presto.py
+++ b/tests/dialects/test_presto.py
@@ -182,12 +182,12 @@ class TestPresto(Validator):
def test_interval_plural_to_singular(self):
# Microseconds, weeks and quarters are not supported in Presto/Trino INTERVAL literals
unit_to_expected = {
- "SeCoNds": "second",
- "minutes": "minute",
- "hours": "hour",
- "days": "day",
- "months": "month",
- "years": "year",
+ "SeCoNds": "SECOND",
+ "minutes": "MINUTE",
+ "hours": "HOUR",
+ "days": "DAY",
+ "months": "MONTH",
+ "years": "YEAR",
}
for unit, expected in unit_to_expected.items():
@@ -279,10 +279,10 @@ class TestPresto(Validator):
},
)
self.validate_all(
- "DATE_ADD('day', 1, x)",
+ "DATE_ADD('DAY', 1, x)",
write={
- "duckdb": "x + INTERVAL 1 day",
- "presto": "DATE_ADD('day', 1, x)",
+ "duckdb": "x + INTERVAL 1 DAY",
+ "presto": "DATE_ADD('DAY', 1, x)",
"hive": "DATE_ADD(x, 1)",
"spark": "DATE_ADD(x, 1)",
},
@@ -582,6 +582,8 @@ class TestPresto(Validator):
},
)
+ self.validate_identity("SELECT a FROM test TABLESAMPLE BERNOULLI (50)")
+ self.validate_identity("SELECT a FROM test TABLESAMPLE SYSTEM (75)")
self.validate_identity("string_agg(x, ',')", "ARRAY_JOIN(ARRAY_AGG(x), ',')")
self.validate_identity("SELECT * FROM x OFFSET 1 LIMIT 1")
self.validate_identity("SELECT * FROM x OFFSET 1 FETCH FIRST 1 ROWS ONLY")
@@ -601,6 +603,16 @@ class TestPresto(Validator):
)
self.validate_all(
+ "SELECT LAST_DAY_OF_MONTH(CAST('2008-11-25' AS DATE))",
+ read={
+ "duckdb": "SELECT LAST_DAY(CAST('2008-11-25' AS DATE))",
+ },
+ write={
+ "duckdb": "SELECT LAST_DAY(CAST('2008-11-25' AS DATE))",
+ "presto": "SELECT LAST_DAY_OF_MONTH(CAST('2008-11-25' AS DATE))",
+ },
+ )
+ self.validate_all(
"SELECT MAX_BY(a.id, a.timestamp) FROM a",
read={
"bigquery": "SELECT MAX_BY(a.id, a.timestamp) FROM a",
@@ -707,9 +719,9 @@ class TestPresto(Validator):
},
)
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("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={