Skip to content

Commit

Permalink
fix(clickhouse): handle nullable nested types
Browse files Browse the repository at this point in the history
I remove the docstring because it is obvious from the type signature,
and the docstring was wrong. The superclass has the correct docstring though,
just inherit that.
  • Loading branch information
NickCrews committed Jun 4, 2024
1 parent 91b0500 commit 6935974
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ibis/backends/sql/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,10 +1016,11 @@ class ClickHouseType(SqlglotType):

@classmethod
def from_ibis(cls, dtype: dt.DataType) -> sge.DataType:
"""Convert a sqlglot type to an ibis type."""
typ = super().from_ibis(dtype)
if dtype.nullable and not (dtype.is_map() or dtype.is_array()):
# map cannot be nullable in clickhouse
# nested types cannot be nullable in clickhouse
if dtype.nullable and not (
dtype.is_map() or dtype.is_array() or dtype.is_struct()
):
return sge.DataType(this=typecode.NULLABLE, expressions=[typ])
else:
return typ
Expand Down

0 comments on commit 6935974

Please sign in to comment.