ArjunPakhan commented on code in PR #3771:
URL: https://github.com/apache/iceberg-python/pull/3771#discussion_r3928350445


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

Review Comment:
   Hi @rambleraptor! 👋
   
   The issue occurs when inspecting tables where a column has undergone 
spec-allowed type promotion (`int` → `long` or `float` → `double`).
   
   Pre-existing manifest entries retain their 4-byte bounds (`IntegerType` / 
`FloatType`). Currently, `_readable_bound` passes the updated 
`field.field_type` (`LongType()` / `DoubleType()`) directly to 
`from_bytes(field.field_type, bound)`. 
   
   Because `from_bytes` uses `_LONG_STRUCT.unpack(bound)` (which expects 8 
bytes), passing a 4-byte bound directly raises `struct.error: unpack requires a 
buffer of 8 bytes` (reproducible in #3744 when calling `inspect.files()`, 
`inspect.entries()`, or `inspect.manifests()`).
   
   Our handling in `_readable_bound` checks the byte buffer length first: if 
`len(bound) == 4` for a `LongType` or `DoubleType` field, it decodes using 
`IntegerType()` or `FloatType()` before returning the promoted value, 
preventing the struct unpack error.
   
   You can verify the exact failure mode by running 
`test_readable_bound_type_promotions` or the e2e test in 
`tests/table/test_inspect.py` against `main` without this branch!



-- 
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