edponce edited a comment on pull request #10727:
URL: https://github.com/apache/arrow/pull/10727#issuecomment-880964640


   *Food for thought:* Tests fail for 
`std::numeric_limits<Int64/Uint64>::min/max()` due to an invalid range when a 
`Scalar[Int64/Uint64]` input is checked against a `Scalar[Float64]` output. 
Similarly, if output is `Scalar[Float32]` tests will fail for `Int32/Uint32` 
cases. This error is triggered by the [Arrow testing logic when casting 
integer-to-floating](https://github.com/apache/arrow/blob/master/cpp/src/arrow/compute/kernels/scalar_cast_numeric.cc#L195-L209)
 for comparing values in test assertions. This is normal behavior as not all 
integers have a floating-point representation.
   
   An example test is:
   ```
   auto min = std::numeric_limits<unsigned long long>::min();
   auto max = std::numeric_limits<unsigned long long>::max();
   this->AssertUnaryOp(floor, this->MakeScalar(min), 
*arrow::MakeScalar(float64(), min));
   this->AssertUnaryOp(floor, this->MakeScalar(max), 
*arrow::MakeScalar(float64(), max));
   ```
   and the error message is:
   ```
   '_error_or_value11.status()' failed with Invalid: Integer value 
18446744073709551615
     not in range: 0 to 9007199254740992
   ```
   The meaning of these numbers is:
   ```
   max(Uint64) = 18446744073709551615
   max(2^53) = 9007199254740992  // mantissa of Float64 = 53
   ```
   
   There are two alternatives to handle min/max tests:
   1. Do not test min/max for cases that have integral inputs and 
floating-point outputs
   2. Create a `TYPED_TEST_SUITE` that uses integral types of up to a width 
that is less than the mantissa of the floating-point output type


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


Reply via email to