From fe322baecabe57898941d35b4b6b2db34f4ab73d Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Tue, 1 Oct 2024 07:08:10 -0400 Subject: [PATCH] fix(polars): handle `pl.Array` --- ibis/formats/polars.py | 2 +- ibis/formats/tests/test_polars.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ibis/formats/polars.py b/ibis/formats/polars.py index 20cc8998d4a45..b49ceb7e6797e 100644 --- a/ibis/formats/polars.py +++ b/ibis/formats/polars.py @@ -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( diff --git a/ibis/formats/tests/test_polars.py b/ibis/formats/tests/test_polars.py index 201e42db1ad02..d641dd096c05e 100644 --- a/ibis/formats/tests/test_polars.py +++ b/ibis/formats/tests/test_polars.py @@ -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)