Skip to content

Commit

Permalink
Fix(duckdb): enable support for user-defined types (#4702)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgesittas authored Feb 4, 2025
1 parent b842d93 commit 5f90307
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sqlglot/dialects/duckdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def _json_extract_value_array_sql(

class DuckDB(Dialect):
NULL_ORDERING = "nulls_are_last"
SUPPORTS_USER_DEFINED_TYPES = False
SUPPORTS_USER_DEFINED_TYPES = True
SAFE_DIVISION = True
INDEX_OFFSET = 1
CONCAT_COALESCE = True
Expand Down
1 change: 1 addition & 0 deletions tests/dialects/test_duckdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def test_duckdb(self):
parse_one("a // b", read="duckdb").assert_is(exp.IntDiv).sql(dialect="duckdb"), "a // b"
)

self.validate_identity("CAST(x AS FOO)")
self.validate_identity("SELECT UNNEST([1, 2])").selects[0].assert_is(exp.UDTF)
self.validate_identity("'red' IN flags").args["field"].assert_is(exp.Column)
self.validate_identity("'red' IN tbl.flags")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_transpile.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ def test_types(self):
self.validate("CAST(x AS INT)::BOOLEAN", "CAST(CAST(x AS INT) AS BOOLEAN)")

with self.assertRaises(ParseError):
transpile("x::z", read="duckdb")
transpile("x::z", read="clickhouse")

def test_not_range(self):
self.validate("a NOT LIKE b", "NOT a LIKE b")
Expand Down

0 comments on commit 5f90307

Please sign in to comment.