hussein-awala commented on code in PR #458:
URL: https://github.com/apache/iceberg-python/pull/458#discussion_r1496666049


##########
pyiceberg/io/pyarrow.py:
##########
@@ -689,15 +689,28 @@ def _(obj: pa.StructType, visitor: 
PyArrowSchemaVisitor[T]) -> T:
     return visitor.struct(obj, results)
 
 
-@visit_pyarrow.register(pa.ListType)
-def _(obj: pa.ListType, visitor: PyArrowSchemaVisitor[T]) -> T:
+def process_list_type(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)
-
     return visitor.list(obj, result)
 
 
+@visit_pyarrow.register(pa.ListType)

Review Comment:
   I tried to create a new type variable equals to `Union[pa.ListType, 
pa.LargeListType, pa.FixedSizeListType], visitor: PyArrowSchemaVisitor[T]` and 
use it in a single register, but MyPy didn't like it:
   ```
   pyiceberg/io/pyarrow.py:695: error: No overload variant of "register" of 
"_SingleDispatchCallable" matches argument type "<typing special form>"  
[call-overload]
   pyiceberg/io/pyarrow.py:695: note: Possible overload variants:
   pyiceberg/io/pyarrow.py:695: note:     def register(self, cls: type[Any], 
func: None = ...) -> Callable[[Callable[..., T]], Callable[..., T]]
   pyiceberg/io/pyarrow.py:695: note:     def register(self, cls: Callable[..., 
T], func: None = ...) -> Callable[..., T]
   pyiceberg/io/pyarrow.py:695: note:     def register(self, cls: type[Any], 
func: Callable[..., T]) -> Callable[..., T]
   ```
   So I moved the transformation to a new method with the Union types and I 
created 3 different register, one for each type of the union.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to