summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_duckdb.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-27 04:28:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-27 04:28:31 +0000
commitbe50d61f0b93ed6b4ee2aba329f998b3fab36be7 (patch)
treee02ee1e74adf0e1b3542f2c41ec917a23b943793 /tests/dialects/test_duckdb.py
parentAdding upstream version 25.6.1. (diff)
downloadsqlglot-be50d61f0b93ed6b4ee2aba329f998b3fab36be7.tar.xz
sqlglot-be50d61f0b93ed6b4ee2aba329f998b3fab36be7.zip
Adding upstream version 25.7.1.upstream/25.7.1
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.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/dialects/test_duckdb.py b/tests/dialects/test_duckdb.py
index bcabd20..d092d3b 100644
--- a/tests/dialects/test_duckdb.py
+++ b/tests/dialects/test_duckdb.py
@@ -309,6 +309,14 @@ class TestDuckDB(Validator):
"SELECT (c -> '$.k1') = 'v1'",
)
self.validate_identity(
+ "SELECT JSON_EXTRACT(c, '$[*].id')[0:2]",
+ "SELECT (c -> '$[*].id')[0 : 2]",
+ )
+ self.validate_identity(
+ "SELECT JSON_EXTRACT_STRING(c, '$[*].id')[0:2]",
+ "SELECT (c ->> '$[*].id')[0 : 2]",
+ )
+ self.validate_identity(
"""SELECT '{"foo": [1, 2, 3]}' -> 'foo' -> 0""",
"""SELECT '{"foo": [1, 2, 3]}' -> '$.foo' -> '$[0]'""",
)
@@ -1048,7 +1056,14 @@ class TestDuckDB(Validator):
"CAST([STRUCT_PACK(a := 1)] AS STRUCT(a BIGINT)[])",
"CAST([ROW(1)] AS STRUCT(a BIGINT)[])",
)
-
+ self.validate_identity(
+ "STRUCT_PACK(a := 'b')::json",
+ "CAST({'a': 'b'} AS JSON)",
+ )
+ self.validate_identity(
+ "STRUCT_PACK(a := 'b')::STRUCT(a TEXT)",
+ "CAST(ROW('b') AS STRUCT(a TEXT))",
+ )
self.validate_all(
"CAST(x AS VARCHAR(5))",
write={