summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_duckdb.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-14 10:12:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-08-14 10:12:13 +0000
commitcdffd0b29d5b072639bb02118d6828f4d1b76099 (patch)
tree57ec0b75c40e40a33060b63599bbba6f0af27ae8 /tests/dialects/test_duckdb.py
parentAdding upstream version 17.11.0. (diff)
downloadsqlglot-cdffd0b29d5b072639bb02118d6828f4d1b76099.tar.xz
sqlglot-cdffd0b29d5b072639bb02118d6828f4d1b76099.zip
Adding upstream version 17.12.0.upstream/17.12.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_duckdb.py')
-rw-r--r--tests/dialects/test_duckdb.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/tests/dialects/test_duckdb.py b/tests/dialects/test_duckdb.py
index 5c35d8f..c33c899 100644
--- a/tests/dialects/test_duckdb.py
+++ b/tests/dialects/test_duckdb.py
@@ -337,6 +337,8 @@ class TestDuckDB(Validator):
unsupported_level=ErrorLevel.IMMEDIATE,
)
+ self.validate_identity("SELECT ISNAN(x)")
+
def test_time(self):
self.validate_identity("SELECT CURRENT_DATE")
self.validate_identity("SELECT CURRENT_TIMESTAMP")
@@ -399,7 +401,7 @@ class TestDuckDB(Validator):
"bigquery": "TIME_TO_STR(x, '%y-%-m-%S')",
"duckdb": "STRFTIME(x, '%y-%-m-%S')",
"postgres": "TO_CHAR(x, 'YY-FMMM-SS')",
- "presto": "DATE_FORMAT(x, '%y-%c-%S')",
+ "presto": "DATE_FORMAT(x, '%y-%c-%s')",
"spark": "DATE_FORMAT(x, 'yy-M-ss')",
},
)
@@ -497,8 +499,12 @@ class TestDuckDB(Validator):
self.validate_identity("CAST(x AS USMALLINT)")
self.validate_identity("CAST(x AS UTINYINT)")
self.validate_identity("CAST(x AS TEXT)")
+ self.validate_identity("CAST(x AS INT128)")
+ self.validate_identity("CAST(x AS DOUBLE)")
+ self.validate_identity("CAST(x AS DECIMAL(15, 4))")
- self.validate_all("CAST(x AS NUMERIC)", write={"duckdb": "CAST(x AS DOUBLE)"})
+ self.validate_all("CAST(x AS NUMERIC(1, 2))", write={"duckdb": "CAST(x AS DECIMAL(1, 2))"})
+ self.validate_all("CAST(x AS HUGEINT)", write={"duckdb": "CAST(x AS INT128)"})
self.validate_all("CAST(x AS CHAR)", write={"duckdb": "CAST(x AS TEXT)"})
self.validate_all("CAST(x AS BPCHAR)", write={"duckdb": "CAST(x AS TEXT)"})
self.validate_all("CAST(x AS STRING)", write={"duckdb": "CAST(x AS TEXT)"})
@@ -514,6 +520,20 @@ class TestDuckDB(Validator):
self.validate_all("CAST(x AS VARBINARY)", write={"duckdb": "CAST(x AS BLOB)"})
self.validate_all("CAST(x AS LOGICAL)", write={"duckdb": "CAST(x AS BOOLEAN)"})
self.validate_all(
+ "CAST(x AS NUMERIC)",
+ write={
+ "duckdb": "CAST(x AS DECIMAL(18, 3))",
+ "postgres": "CAST(x AS DECIMAL(18, 3))",
+ },
+ )
+ self.validate_all(
+ "CAST(x AS DECIMAL)",
+ write={
+ "duckdb": "CAST(x AS DECIMAL(18, 3))",
+ "postgres": "CAST(x AS DECIMAL(18, 3))",
+ },
+ )
+ self.validate_all(
"CAST(x AS BIT)",
read={
"duckdb": "CAST(x AS BITSTRING)",