vrongmeal opened a new issue, #5507:
URL: https://github.com/apache/arrow-datafusion/issues/5507

   **Describe the bug**
   <!--
   A clear and concise description of what the bug is.
   -->
   
   In the function `try_cast_literal_to_type`: 
https://github.com/apache/arrow-datafusion/blob/928662bb12d915aef83abba1312392d25770f68f/datafusion/optimizer/src/unwrap_cast_in_comparison.rs#L295
   
   Converting from `Timestamp(Nanosecond, _)` to `Timestamp(Microsecond, _)` 
doesn't actually return the correct value. It simply interchanges the inner 
integer.
   
   **To Reproduce**
   <!--
   Steps to reproduce the behavior:
   -->
   
   Running the following:
   
   ```rs
   #[test]
   fn test_repro() {
       let new_scalar = try_cast_literal_to_type(
           &ScalarValue::TimestampNanosecond(Some(123456), None),
           &DataType::Timestamp(TimeUnit::Microsecond, None)
       ).unwrap().unwrap();
   
       // This passes which is wrong
       assert_eq!(new_scalar, ScalarValue::TimestampMicrosecond(Some(123456), 
None));
   
       // This fails!
       // assert_eq!(new_scalar, ScalarValue::TimestampMicrosecond(Some(123), 
None));
   }
   ```
   
   **Expected behavior**
   <!--
   A clear and concise description of what you expected to happen.
   -->
   
   ```rs
   // This should be the correct result
   assert_eq!(new_scalar, ScalarValue::TimestampMicrosecond(Some(123), None));
   ```
   
   **Additional context**
   <!--
   Add any other context about the problem here.
   -->
   


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