summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_redshift.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-11 12:46:06 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-11 12:46:06 +0000
commit9dae42c19381cf27dc56bd932aebd780aa66722b (patch)
treed70521fc9bf401e225f567a2d6acf1c1e4add2fd /tests/dialects/test_redshift.py
parentAdding upstream version 15.0.0. (diff)
downloadsqlglot-9dae42c19381cf27dc56bd932aebd780aa66722b.tar.xz
sqlglot-9dae42c19381cf27dc56bd932aebd780aa66722b.zip
Adding upstream version 15.2.0.upstream/15.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_redshift.py')
-rw-r--r--tests/dialects/test_redshift.py41
1 files changed, 40 insertions, 1 deletions
diff --git a/tests/dialects/test_redshift.py b/tests/dialects/test_redshift.py
index 6707b7a..f4efe24 100644
--- a/tests/dialects/test_redshift.py
+++ b/tests/dialects/test_redshift.py
@@ -11,6 +11,16 @@ class TestRedshift(Validator):
self.validate_identity("$foo")
self.validate_all(
+ "SELECT STRTOL('abc', 16)",
+ read={
+ "trino": "SELECT FROM_BASE('abc', 16)",
+ },
+ write={
+ "redshift": "SELECT STRTOL('abc', 16)",
+ "trino": "SELECT FROM_BASE('abc', 16)",
+ },
+ )
+ self.validate_all(
"SELECT SNAPSHOT, type",
write={
"": "SELECT SNAPSHOT, type",
@@ -19,6 +29,35 @@ class TestRedshift(Validator):
)
self.validate_all(
+ "x is true",
+ write={
+ "redshift": "x IS TRUE",
+ "presto": "x",
+ },
+ )
+ self.validate_all(
+ "x is false",
+ write={
+ "redshift": "x IS FALSE",
+ "presto": "NOT x",
+ },
+ )
+ self.validate_all(
+ "x is not false",
+ write={
+ "redshift": "NOT x IS FALSE",
+ "presto": "NOT NOT x",
+ },
+ )
+ self.validate_all(
+ "LEN(x)",
+ write={
+ "redshift": "LENGTH(x)",
+ "presto": "LENGTH(x)",
+ },
+ )
+
+ self.validate_all(
"SELECT SYSDATE",
write={
"": "SELECT CURRENT_TIMESTAMP()",
@@ -141,7 +180,7 @@ class TestRedshift(Validator):
"DATEDIFF('day', a, b)",
write={
"redshift": "DATEDIFF(day, a, b)",
- "presto": "DATE_DIFF('day', a, b)",
+ "presto": "DATE_DIFF('day', CAST(SUBSTR(CAST(a AS VARCHAR), 1, 10) AS DATE), CAST(SUBSTR(CAST(b AS VARCHAR), 1, 10) AS DATE))",
},
)
self.validate_all(