fallintoplace opened a new issue, #3404:
URL: https://github.com/apache/iceberg-python/issues/3404
## Summary
Large integral string values lose precision in two runtime conversion paths
because they round-trip through `float` before converting to `int`.
This causes valid 64-bit values to be corrupted, including `LongType.max`.
## Affected paths
- `StringLiteral.to(LongType)` in `pyiceberg/expressions/literals.py`
- `partition_to_py` for `LongType`, `TimestampType`, `TimestampNanoType`,
`TimestamptzType`, and `TimestamptzNanoType` in `pyiceberg/conversions.py`
## Minimal repro
```python
from pyiceberg.expressions.literals import literal
from pyiceberg.conversions import partition_to_py
from pyiceberg.types import LongType, TimestampNanoType
print(literal(str(LongType.max)).to(LongType()))
print(literal("9007199254740993").to(LongType()).value)
print(partition_to_py(LongType(), "9007199254740993"))
print(partition_to_py(TimestampNanoType(), "9007199254740993"))
```
## Actual
```python
LongAboveMax
9007199254740992
9007199254740992
9007199254740992
```
## Expected
```python
LongLiteral(9223372036854775807)
9007199254740993
9007199254740993
9007199254740993
```
## Why this happens
Both code paths currently do `int(float(...))`, which loses precision for
large integer values above the IEEE-754 exact integer range.
In particular, this makes `literal(str(LongType.max)).to(LongType())` return
`LongAboveMax` even though `LongType.max` is valid by definition.
## Notes
This looks like one underlying bug rather than two separate issues, since
both paths have the same precision-loss mechanism.
--
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]