rahulsmahadev commented on code in PR #4358: URL: https://github.com/apache/iceberg-python/pull/4358#discussion_r4733850204
########## pyiceberg/table/inspect.py: ########## @@ -39,7 +40,46 @@ 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, lists and maps.""" + import pyarrow as pa + + if isinstance(data_type, pa.BaseExtensionType): + return data_type.storage_type + if pa.types.is_struct(data_type): + return pa.struct([_storage_field(field) for field in data_type]) + if pa.types.is_large_list(data_type): + return pa.large_list(_storage_field(data_type.value_field)) + if pa.types.is_map(data_type): + return pa.map_(_storage_field(data_type.key_field), _storage_field(data_type.item_field)) + return data_type + + Review Comment: Done in 48ab9c61. Plain `list` and `fixed_size_list` are unwrapped too and keep their kind, so a fixed size list stays fixed size. PyIceberg schemas only produce `large_list`, so this matters for hand-built schemas. Added `test_from_pylist_casts_uuid_inside_plain_and_fixed_size_lists`, which fails before with `ArrowNotImplementedError: extension`. -- 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]
