When converting a Date32 outside the range of usec or nanos, cast()/cast_with_options() overflows.
#[test]
fn test_cast_date32_to_timestamp_ns_overflow() {
// 2262-04-11, 2062-04-12
let a = Date32Array::from(vec![Some(106751), Some(106752), None]);
let array = Arc::new(a) as ArrayRef;
let err = cast_with_options(
&array,
&DataType::Timestamp(TimeUnit::Nanosecond, None),
&CastOptions {
safe: false,
format_options: FormatOptions::default(),
},
);
assert!(err.is_err());
let b = cast(&array, &DataType::Timestamp(TimeUnit::Nanosecond, None)).unwrap();
let c = b
.as_any()
.downcast_ref::<TimestampNanosecondArray>()
.unwrap();
assert_eq!(9223286400000000000, c.value(0));
assert!(c.is_null(1));
assert!(c.is_null(2));
}
Behaves similar to the unittest instead of panicing.
Describe the bug
When converting a Date32 outside the range of usec or nanos, cast()/cast_with_options() overflows.
To Reproduce
Expected behavior
Behaves similar to the unittest instead of panicing.
Additional context