[Go] compute.Divide results integer value not in range error
Describe the bug, including details regarding any error messages, version, and platform.
func TestDivide (t *testing. T) {
builder := array.NewInt64Builder(memory.NewGoAllocator())
builder.Append(12345000000000000)
arr := builder.NewArray()
_, err := compute.Divide(context.TODO(), compute.ArithmeticOptions{NoCheckOverflow: false},
&compute.ArrayDatum{Value: arr.Data()},
compute.NewDatum(math.Pow10(int(16))))
if err != nil {
t.Fatal(err)
}
}
is giving me invalid: integer value 12345000000000000 not in range: -9007199254740992 to 9007199254740992
Component(s)
Go
The second argument to the division is compute.NewDatum(math.Pow10(int(16)))) which will be a float64 since that's the type returned by math.Pow10. In the case of an int64 divided by a float64, the integer gets promoted. So it first tries to cast 12345000000000000 to a float64, which is invalid because the largest integer that can be represented by a float64 is 2^53, or 9007199254740992.
If you want to allow the overflow and disable the check, you can change NoCheckOverflow: false to NoCheckOverflow: true.
Closing as it doesn't appear to be a bug or issue on our side. Feel free to reopen if necessary!