From 05575b7ec420b5fc741c76f635aa5ed7e3db4c65 Mon Sep 17 00:00:00 2001 From: Jim Crist-Harif Date: Tue, 13 Feb 2024 14:13:15 -0600 Subject: [PATCH] fix(pyarrow): map date type to arrow date32 not date64 --- ibis/formats/pyarrow.py | 2 +- ibis/formats/tests/test_pyarrow.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ibis/formats/pyarrow.py b/ibis/formats/pyarrow.py index daba4be3ca26..c434fe7ae5c2 100644 --- a/ibis/formats/pyarrow.py +++ b/ibis/formats/pyarrow.py @@ -165,7 +165,7 @@ def from_ibis(cls, dtype: dt.DataType) -> pa.DataType: elif dtype.is_time(): return pa.time64("ns") elif dtype.is_date(): - return pa.date64() + return pa.date32() elif dtype.is_array(): value_field = pa.field( "item", diff --git a/ibis/formats/tests/test_pyarrow.py b/ibis/formats/tests/test_pyarrow.py index dc58587cc8f6..a9c3e892cac3 100644 --- a/ibis/formats/tests/test_pyarrow.py +++ b/ibis/formats/tests/test_pyarrow.py @@ -54,8 +54,8 @@ def test_roundtripable_types(arrow_type): (pa.decimal256(38, 5), dt.Decimal(38, 5, nullable=False), pa.decimal128(38, 5)), (pa.decimal256(39, 6), dt.Decimal(39, 6, nullable=False), pa.decimal256(39, 6)), (pa.decimal256(76, 6), dt.Decimal(76, 6, nullable=False), pa.decimal256(76, 6)), - (pa.date32(), dt.Date(nullable=False), pa.date64()), - (pa.date64(), dt.Date(nullable=False), pa.date64()), + (pa.date32(), dt.Date(nullable=False), pa.date32()), + (pa.date64(), dt.Date(nullable=False), pa.date32()), (pa.time32("s"), dt.Time(nullable=False), pa.time64("ns")), (pa.time32("ms"), dt.Time(nullable=False), pa.time64("ns")), (pa.time64("us"), dt.Time(nullable=False), pa.time64("ns")), @@ -122,7 +122,7 @@ def test_dtype_from_nullable_list_type(value_nullable, list_nullable): assert restored_type.value_field.nullable is value_nullable -@pytest.mark.parametrize("value_type", [pa.string(), pa.date64()]) +@pytest.mark.parametrize("value_type", [pa.string(), pa.date32()]) def test_dtype_from_dictionary_type(value_type): dict_type = pa.dictionary(pa.int32(), value_type) ibis_type = PyArrowType.to_ibis(dict_type)