Skip to content

Commit

Permalink
fix(polars): handle pl.Array
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Oct 1, 2024
1 parent 41462c5 commit fe322ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ibis/formats/polars.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def to_ibis(cls, typ: pl.DataType, nullable=True) -> dt.DataType:
except AttributeError: # pragma: no cover
time_unit = typ.tu # pragma: no cover
return dt.Interval(unit=time_unit, nullable=nullable)
elif base_type is pl.List:
elif base_type is pl.List or base_type is pl.Array:
return dt.Array(cls.to_ibis(typ.inner), nullable=nullable)
elif base_type is pl.Struct:
return dt.Struct.from_tuples(
Expand Down
4 changes: 4 additions & 0 deletions ibis/formats/tests/test_polars.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,7 @@ def test_convert_table():
)
assert df.equals(sol)
assert df.schema == sol.schema


def test_array_type():
assert PolarsType.to_ibis(pl.Array(pl.Int64, 2)) == dt.Array(dt.int64)

Check warning on line 177 in ibis/formats/tests/test_polars.py

View check run for this annotation

Codecov / codecov/patch

ibis/formats/tests/test_polars.py#L177

Added line #L177 was not covered by tests

0 comments on commit fe322ba

Please sign in to comment.