From d2e9401b18925b5702c5c758af7d4f5b61deb493 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 May 2023 08:44:54 +0200 Subject: Adding upstream version 12.2.0. Signed-off-by: Daniel Baumann --- tests/dialects/test_presto.py | 45 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'tests/dialects/test_presto.py') diff --git a/tests/dialects/test_presto.py b/tests/dialects/test_presto.py index 3080476..15962cc 100644 --- a/tests/dialects/test_presto.py +++ b/tests/dialects/test_presto.py @@ -6,6 +6,26 @@ class TestPresto(Validator): dialect = "presto" def test_cast(self): + self.validate_all( + "FROM_BASE64(x)", + read={ + "hive": "UNBASE64(x)", + }, + write={ + "hive": "UNBASE64(x)", + "presto": "FROM_BASE64(x)", + }, + ) + self.validate_all( + "TO_BASE64(x)", + read={ + "hive": "BASE64(x)", + }, + write={ + "hive": "BASE64(x)", + "presto": "TO_BASE64(x)", + }, + ) self.validate_all( "CAST(a AS ARRAY(INT))", write={ @@ -105,6 +125,13 @@ class TestPresto(Validator): "spark": "SIZE(x)", }, ) + self.validate_all( + "ARRAY_JOIN(x, '-', 'a')", + write={ + "hive": "CONCAT_WS('-', x)", + "spark": "ARRAY_JOIN(x, '-', 'a')", + }, + ) def test_interval_plural_to_singular(self): # Microseconds, weeks and quarters are not supported in Presto/Trino INTERVAL literals @@ -133,6 +160,14 @@ class TestPresto(Validator): self.validate_identity("TRIM(a, b)") self.validate_identity("VAR_POP(a)") + self.validate_all( + "SELECT FROM_UNIXTIME(col) FROM tbl", + write={ + "presto": "SELECT FROM_UNIXTIME(col) FROM tbl", + "spark": "SELECT CAST(FROM_UNIXTIME(col) AS TIMESTAMP) FROM tbl", + "trino": "SELECT FROM_UNIXTIME(col) FROM tbl", + }, + ) self.validate_all( "DATE_FORMAT(x, '%Y-%m-%d %H:%i:%S')", write={ @@ -181,7 +216,7 @@ class TestPresto(Validator): "duckdb": "TO_TIMESTAMP(x)", "presto": "FROM_UNIXTIME(x)", "hive": "FROM_UNIXTIME(x)", - "spark": "FROM_UNIXTIME(x)", + "spark": "CAST(FROM_UNIXTIME(x) AS TIMESTAMP)", }, ) self.validate_all( @@ -583,6 +618,14 @@ class TestPresto(Validator): }, ) + self.validate_all( + "JSON_FORMAT(JSON 'x')", + write={ + "presto": "JSON_FORMAT(CAST('x' AS JSON))", + "spark": "TO_JSON('x')", + }, + ) + def test_encode_decode(self): self.validate_all( "TO_UTF8(x)", -- cgit v1.2.3