rahulsmahadev commented on code in PR #4358:
URL: https://github.com/apache/iceberg-python/pull/4358#discussion_r4688365006


##########
pyiceberg/table/inspect.py:
##########
@@ -39,7 +40,36 @@
 
 
 def _readable_bound(field_type: PrimitiveType, bound: bytes | None) -> Any | 
None:
-    return from_bytes(field_type, bound) if bound is not None else None
+    return _storage_value(from_bytes(field_type, bound)) if bound is not None 
else None
+
+
+def _storage_type(data_type: pa.DataType) -> pa.DataType:

Review Comment:
   Good catch, thanks. readable_metrics types the bounds of a top-level list or 
map column with the column's type, so `list<uuid>` and `map<string, uuid>` 
columns still failed. `_storage_type` now also replaces extension types inside 
lists and maps, and `test_inspect_files_and_entries_with_uuid_in_list_and_map` 
covers both. It fails without the change with `ArrowNotImplementedError: 
extension`.



##########
pyiceberg/table/inspect.py:
##########
@@ -39,7 +40,36 @@
 
 
 def _readable_bound(field_type: PrimitiveType, bound: bytes | None) -> Any | 
None:
-    return from_bytes(field_type, bound) if bound is not None else None
+    return _storage_value(from_bytes(field_type, bound)) if bound is not None 
else None
+
+
+def _storage_type(data_type: pa.DataType) -> pa.DataType:
+    """Return the storage type of a data type, replacing extension types 
inside structs."""
+    import pyarrow as pa
+
+    if isinstance(data_type, pa.BaseExtensionType):
+        return data_type.storage_type
+    if pa.types.is_struct(data_type):

Review Comment:
   Thanks for checking. The rows are only built with the storage types: 
`_from_pylist` casts the result back to the full schema, so the geoarrow type 
keeps its metadata. I checked a geometry bound (`{"crs": "srid:3857"}`) and a 
geography bound (`{"edges": "spherical", "crs": "srid:4269"}`): the output 
schema equals the original and the WKB value is unchanged. With 
`pa.Table.from_pylist`, which main uses, both fail with 
`ArrowNotImplementedError: extension` when geoarrow-types is installed, so this 
also fixes these tables for geo columns. Happy to add a test for it if you'd 
like.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to