Describe the bug
round() currently exhibits incorrect behavior for large integer inputs.
For Int64 values greater than 2^53 (9007199254740992), which is the largest integer exactly representable in Float64, round() loses precision and return a different value than the input even though rounding an integer with a non-negative scale should be a no-op. This is partially inspired from #22567 by @neilconway
Example:
SELECT round(arrow_cast(9007199254740993, 'Int64'));
Current output:
Expected output:
The returned value differs from the input even though no rounding is required.
The same issue can be observed with the two-argument form:
SELECT round(arrow_cast(9007199254740993, 'Int64'), 2);
Current output:
Expected output:
Related behavior with large UInt64 values
For UInt64 values that exceed i64::MAX, round() fails even when the operation is effectively a no-op.
Example:
SELECT round(arrow_cast(18446744073709551615, 'UInt64'));
Current output:
DataFusion error: Execution error:
round: UInt64 value 18446744073709551615 exceeds i64::MAX and cannot be rounded
Expected output:
Similarly:
SELECT round(arrow_cast(18446744073709551615, 'UInt64'), 2);
Current output:
DataFusion error: Execution error:
round: UInt64 value 18446744073709551615 exceeds i64::MAX and cannot be rounded
Expected output:
Describe the bug
round()currently exhibits incorrect behavior for large integer inputs.For Int64 values greater than 2^53 (9007199254740992), which is the largest integer exactly representable in Float64, round() loses precision and return a different value than the input even though rounding an integer with a non-negative scale should be a no-op. This is partially inspired from #22567 by @neilconway
Example:
Current output:
Expected output:
The returned value differs from the input even though no rounding is required.
The same issue can be observed with the two-argument form:
Current output:
Expected output:
Related behavior with large UInt64 values
For UInt64 values that exceed i64::MAX, round() fails even when the operation is effectively a no-op.
Example:
Current output:
Expected output:
Similarly:
Current output:
Expected output: