summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_presto.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-20 09:22:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-20 09:22:22 +0000
commit281115ae80458761fb3593c81fe9488976b87c6d (patch)
treef159075e865f3bad227b365878dc315eeab64112 /tests/dialects/test_presto.py
parentAdding upstream version 18.4.1. (diff)
downloadsqlglot-281115ae80458761fb3593c81fe9488976b87c6d.tar.xz
sqlglot-281115ae80458761fb3593c81fe9488976b87c6d.zip
Adding upstream version 18.5.1.upstream/18.5.1
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.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/tests/dialects/test_presto.py b/tests/dialects/test_presto.py
index dbca5b3..a92f04f 100644
--- a/tests/dialects/test_presto.py
+++ b/tests/dialects/test_presto.py
@@ -358,6 +358,10 @@ class TestPresto(Validator):
write={"presto": "CAST(x AS TIMESTAMP)"},
read={"mysql": "CAST(x AS DATETIME)", "clickhouse": "CAST(x AS DATETIME64)"},
)
+ self.validate_all(
+ "CAST(x AS TIMESTAMP)",
+ read={"mysql": "TIMESTAMP(x)"},
+ )
def test_ddl(self):
self.validate_all(
@@ -518,6 +522,14 @@ class TestPresto(Validator):
)
self.validate_all(
+ """JSON '"foo"'""",
+ write={
+ "bigquery": """PARSE_JSON('"foo"')""",
+ "presto": """JSON_PARSE('"foo"')""",
+ "snowflake": """PARSE_JSON('"foo"')""",
+ },
+ )
+ self.validate_all(
"SELECT ROW(1, 2)",
read={
"spark": "SELECT STRUCT(1, 2)",
@@ -824,9 +836,9 @@ class TestPresto(Validator):
self.validate_all(
"""JSON_FORMAT(JSON '"x"')""",
write={
- "bigquery": """TO_JSON_STRING(JSON '"x"')""",
- "duckdb": """CAST(TO_JSON(CAST('"x"' AS JSON)) AS TEXT)""",
- "presto": """JSON_FORMAT(CAST('"x"' AS JSON))""",
+ "bigquery": """TO_JSON_STRING(PARSE_JSON('"x"'))""",
+ "duckdb": """CAST(TO_JSON(JSON('"x"')) AS TEXT)""",
+ "presto": """JSON_FORMAT(JSON_PARSE('"x"'))""",
"spark": """REGEXP_EXTRACT(TO_JSON(FROM_JSON('["x"]', SCHEMA_OF_JSON('["x"]'))), '^.(.*).$', 1)""",
},
)
@@ -916,14 +928,14 @@ class TestPresto(Validator):
"SELECT CAST(JSON '[1,23,456]' AS ARRAY(INTEGER))",
write={
"spark": "SELECT FROM_JSON('[1,23,456]', 'ARRAY<INT>')",
- "presto": "SELECT CAST(CAST('[1,23,456]' AS JSON) AS ARRAY(INTEGER))",
+ "presto": "SELECT CAST(JSON_PARSE('[1,23,456]') AS ARRAY(INTEGER))",
},
)
self.validate_all(
"""SELECT CAST(JSON '{"k1":1,"k2":23,"k3":456}' AS MAP(VARCHAR, INTEGER))""",
write={
"spark": 'SELECT FROM_JSON(\'{"k1":1,"k2":23,"k3":456}\', \'MAP<STRING, INT>\')',
- "presto": 'SELECT CAST(CAST(\'{"k1":1,"k2":23,"k3":456}\' AS JSON) AS MAP(VARCHAR, INTEGER))',
+ "presto": 'SELECT CAST(JSON_PARSE(\'{"k1":1,"k2":23,"k3":456}\') AS MAP(VARCHAR, INTEGER))',
},
)