-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Description
Describe the bug
Casting a floating point number like 1.1_f64
to decimal64 fails.
To Reproduce
The following test fails, but only for Decimal64
.
#[test]
fn test_cast_floating_to_decimals() {
for output_type in [
DataType::Decimal32(9, 3),
DataType::Decimal64(9, 3),
DataType::Decimal128(9, 3),
DataType::Decimal256(9, 3),
] {
let input_type = DataType::Float64;
assert!(can_cast_types(&input_type, &output_type));
let array = vec![Some(1.1_f64)];
let array = PrimitiveArray::<Float64Type>::from_iter(array);
let result = cast_with_options(
&array,
&output_type,
&CastOptions {
safe: false,
format_options: FormatOptions::default(),
},
);
assert!(
result.is_ok(),
"Failed to cast to {output_type} with: {}",
result.unwrap_err().to_string()
);
}
}
Expected behavior
This cast operation should work for all decimal types.
Additional context