Skip to content

Commit 5f90307

Browse files
authored
Fix(duckdb): enable support for user-defined types (#4702)
1 parent b842d93 commit 5f90307

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

sqlglot/dialects/duckdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def _json_extract_value_array_sql(
272272

273273
class DuckDB(Dialect):
274274
NULL_ORDERING = "nulls_are_last"
275-
SUPPORTS_USER_DEFINED_TYPES = False
275+
SUPPORTS_USER_DEFINED_TYPES = True
276276
SAFE_DIVISION = True
277277
INDEX_OFFSET = 1
278278
CONCAT_COALESCE = True

tests/dialects/test_duckdb.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ def test_duckdb(self):
256256
parse_one("a // b", read="duckdb").assert_is(exp.IntDiv).sql(dialect="duckdb"), "a // b"
257257
)
258258

259+
self.validate_identity("CAST(x AS FOO)")
259260
self.validate_identity("SELECT UNNEST([1, 2])").selects[0].assert_is(exp.UDTF)
260261
self.validate_identity("'red' IN flags").args["field"].assert_is(exp.Column)
261262
self.validate_identity("'red' IN tbl.flags")

tests/test_transpile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ def test_types(self):
610610
self.validate("CAST(x AS INT)::BOOLEAN", "CAST(CAST(x AS INT) AS BOOLEAN)")
611611

612612
with self.assertRaises(ParseError):
613-
transpile("x::z", read="duckdb")
613+
transpile("x::z", read="clickhouse")
614614

615615
def test_not_range(self):
616616
self.validate("a NOT LIKE b", "NOT a LIKE b")

0 commit comments

Comments
 (0)