badalprasadsingh opened a new issue, #1322:
URL: https://github.com/apache/iceberg-go/issues/1322
### Apache Iceberg version
main (development)
### Please describe the bug 🐞
In Iceberg-Go, `DecimalLiteral.To(Int32Type)` in `literals.go` converts a
decimal to `Int32` like this:
```go
case Int32Type:
v := d.Val.BigInt().Int64()
if v > math.MaxInt32 {
return Int32AboveMaxLiteral(), nil
} else if v < math.MinInt32 {
return Int32BelowMinLiteral(), nil
}
return Int32Literal(int32(v)), nil
```
A `(*big.Int).Int64()` does not preserve the original value when the value
does not fit in the `int64` range.
Consequence: the comparison against `MaxInt32` / `MinInt32`:
- pick the _wrong_ sentinel direction (e.g. unscaled `2^63` wraps to
`math.MinInt64` and is reported as `Int32BelowMin` instead of `Int32AboveMax`),
or
- pick no sentinel at all, returning a spurious in-range `Int32Literal`
(e.g. unscaled `-(2^64-1)` wraps to `+1`).
--
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]