alec-heif opened a new issue, #6210:
URL: https://github.com/apache/iceberg/issues/6210

   ### Apache Iceberg version
   
   _No response_
   
   ### Query engine
   
   _No response_
   
   ### Please describe the bug 🐞
   
   The logic in 
https://github.com/apache/iceberg/blob/master/python/pyiceberg/avro/decoder.py#L70
 appears to be incorrect.
   
   The spec for a binary-encoded `int` in the manifest files is [as 
follows:](https://iceberg.apache.org/spec/#binary-single-value-serialization)
   
   ```
   int | Stored as 4-byte little-endian
   ```
   
   so, an example bytestring of `0xad4a0000` should be read as the decimal 
`19117`:
   
   1. lsb `0xad` is 173
   2. 2nd lsb `0x4a` is 74
   3. (74 * 256) + 173 == 19117
   
   however `BinaryDecoder` does not read this correctly:
   ```
   import io
   def as_fo(x):
       return io.BytesIO(bytes.fromhex('ad4a0000'))
   
   assert as_fo('ad4a0000').read(4).hex() == 'ad4a0000'
   assert BinaryDecoder(as_io('ad4a0000')).read_int() == -4759
   ```
   
   it is not obvious by inspection of `BinaryDecoder.read_int` where the bug 
is, but it is clearly a bug.


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