This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git


The following commit(s) were added to refs/heads/main by this push:
     new 5ea0617  Accept pyarrow `LargeListType` and `FixedSizeListType` (#458)
5ea0617 is described below

commit 5ea0617c2e34e596db296778d1f00ec3fad59d59
Author: Hussein Awala <[email protected]>
AuthorDate: Wed Feb 21 14:16:51 2024 +0100

    Accept pyarrow `LargeListType` and `FixedSizeListType` (#458)
    
    * Accept pyarrow LargeListType and FixedSizeListType
    
    * Combine the 3 register in one
---
 pyiceberg/io/pyarrow.py          |  4 +++-
 tests/io/test_pyarrow_visitor.py | 20 ++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/pyiceberg/io/pyarrow.py b/pyiceberg/io/pyarrow.py
index f391abf..76bb041 100644
--- a/pyiceberg/io/pyarrow.py
+++ b/pyiceberg/io/pyarrow.py
@@ -690,7 +690,9 @@ def _(obj: pa.StructType, visitor: PyArrowSchemaVisitor[T]) 
-> T:
 
 
 @visit_pyarrow.register(pa.ListType)
-def _(obj: pa.ListType, visitor: PyArrowSchemaVisitor[T]) -> T:
+@visit_pyarrow.register(pa.FixedSizeListType)
+@visit_pyarrow.register(pa.LargeListType)
+def _(obj: Union[pa.ListType, pa.LargeListType, pa.FixedSizeListType], 
visitor: PyArrowSchemaVisitor[T]) -> T:
     visitor.before_list_element(obj.value_field)
     result = visit_pyarrow(obj.value_type, visitor)
     visitor.after_list_element(obj.value_field)
diff --git a/tests/io/test_pyarrow_visitor.py b/tests/io/test_pyarrow_visitor.py
index 7d35cae..5b55bd6 100644
--- a/tests/io/test_pyarrow_visitor.py
+++ b/tests/io/test_pyarrow_visitor.py
@@ -245,6 +245,26 @@ def test_pyarrow_list_to_iceberg() -> None:
     assert visit_pyarrow(pyarrow_list, _ConvertToIceberg()) == expected
 
 
+def test_pyarrow_large_list_to_iceberg() -> None:
+    pyarrow_list = pa.large_list(pa.field("element", pa.int32(), 
nullable=False, metadata={"PARQUET:field_id": "1"}))
+    expected = ListType(
+        element_id=1,
+        element_type=IntegerType(),
+        element_required=True,
+    )
+    assert visit_pyarrow(pyarrow_list, _ConvertToIceberg()) == expected
+
+
+def test_pyarrow_fixed_size_list_to_iceberg() -> None:
+    pyarrow_list = pa.list_(pa.field("element", pa.int32(), nullable=False, 
metadata={"PARQUET:field_id": "1"}), 1)
+    expected = ListType(
+        element_id=1,
+        element_type=IntegerType(),
+        element_required=True,
+    )
+    assert visit_pyarrow(pyarrow_list, _ConvertToIceberg()) == expected
+
+
 def test_pyarrow_map_to_iceberg() -> None:
     pyarrow_map = pa.map_(
         pa.field("key", pa.int32(), nullable=False, 
metadata={"PARQUET:field_id": "1"}),

Reply via email to