summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_presto.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-29 13:02:26 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-29 13:02:26 +0000
commita299be925028c6243d34b020920dfd0135bb9574 (patch)
tree39a7a231466fd9d139047a67672f09040dd23394 /tests/dialects/test_presto.py
parentAdding upstream version 16.4.2. (diff)
downloadsqlglot-a299be925028c6243d34b020920dfd0135bb9574.tar.xz
sqlglot-a299be925028c6243d34b020920dfd0135bb9574.zip
Adding upstream version 16.7.3.upstream/16.7.3
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.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/dialects/test_presto.py b/tests/dialects/test_presto.py
index 852b494..49139f9 100644
--- a/tests/dialects/test_presto.py
+++ b/tests/dialects/test_presto.py
@@ -1,3 +1,5 @@
+from unittest import mock
+
from sqlglot import UnsupportedError
from tests.dialects.test_dialect import Validator
@@ -439,7 +441,8 @@ class TestPresto(Validator):
},
)
- def test_presto(self):
+ @mock.patch("sqlglot.helper.logger")
+ def test_presto(self, mock_logger):
self.validate_identity("SELECT * FROM x OFFSET 1 LIMIT 1")
self.validate_identity("SELECT * FROM x OFFSET 1 FETCH FIRST 1 ROWS ONLY")
self.validate_identity("SELECT BOOL_OR(a > 10) FROM asd AS T(a)")
@@ -453,6 +456,21 @@ class TestPresto(Validator):
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 COALESCE(ELEMENT_AT(MAP_FROM_ENTRIES(ARRAY[(51, '1')]), id), quantity) FROM my_table",
+ write={
+ "postgres": UnsupportedError,
+ "presto": "SELECT COALESCE(ELEMENT_AT(MAP_FROM_ENTRIES(ARRAY[(51, '1')]), id), quantity) FROM my_table",
+ },
+ )
+ self.validate_all(
+ "SELECT ELEMENT_AT(ARRAY[1, 2, 3], 4)",
+ write={
+ "": "SELECT ARRAY(1, 2, 3)[3]",
+ "postgres": "SELECT (ARRAY[1, 2, 3])[4]",
+ "presto": "SELECT ELEMENT_AT(ARRAY[1, 2, 3], 4)",
+ },
+ )
+ self.validate_all(
"SELECT SUBSTRING(a, 1, 3), SUBSTRING(a, LENGTH(a) - (3 - 1))",
read={
"redshift": "SELECT LEFT(a, 3), RIGHT(a, 3)",