Jefffrey opened a new issue, #10131:
URL: https://github.com/apache/arrow-rs/issues/10131
### Describe the bug
some of the cast paths (for temporal types like time/date/timestamp) don't
protect against overflows/underflows/panics properly.
### To Reproduce
```rust
// arrow-cast/src/cast/mod.rs
#[test]
fn test123() {
let a = Date64Array::from(vec![i64::MAX]);
let b = cast(&a, &DataType::Date32).unwrap();
let b = b.as_primitive::<Date32Type>();
dbg!(b.value(0)); // outputs -622191233
let a = Time32SecondArray::from(vec![i32::MAX]);
let _ = cast(&a, &DataType::Time32(TimeUnit::Millisecond));
}
```
output of test
```sh
running 1 test
[arrow-cast/src/cast/mod.rs:13904:9] b.value(0) = -622191233
thread 'cast::tests::test123' (6354242) panicked at
arrow-cast/src/cast/mod.rs:1722:56:
attempt to multiply with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
test cast::tests::test123 ... FAILED
failures:
failures:
cast::tests::test123
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 352 filtered
out; finished in 0.00s
error: test failed, to rerun pass `-p arrow-cast --lib`
```
### Expected behavior
for the date64 -> date32, we underflow to a negative value. we should
respect the cast safety option (either null it or explicitly error)
for time32 second -> time32 milli it panics. same as above, we should
respect the cast safety option.
### Additional context
inspired by https://github.com/apache/arrow-rs/issues/9824
--
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]