Repository navigation
Closed
Labels
enhancementNew feature/addition
Description
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
Casting of decimals with negative scale
Describe the solution you'd like
Example test:
// arrow-cast/src/cast/mod.rs
#[test]
fn test_cast_decimal_to_numeric_negative_scale() {
let value_array: Vec<Option<i256>> = vec![
Some(i256::from_i128(125)),
Some(i256::from_i128(225)),
Some(i256::from_i128(325)),
None,
Some(i256::from_i128(525)),
];
let array = create_decimal256_array(value_array, 38, -1).unwrap();
generate_cast_test_case!(
&array,
Int64Array,
&DataType::Int64,
vec![Some(1_250), Some(2_250), Some(3_250), None, Some(5_250)]
);
}Currently this fails with error:
failures:
---- cast::tests::test_cast_decimal_to_numeric_negative_scale stdout ----
thread 'cast::tests::test_cast_decimal_to_numeric_negative_scale' (5901100) panicked at arrow-cast/src/cast/mod.rs:3725:9:
called `Result::unwrap()` on an `Err` value: CastError("Cannot cast to \"Decimal256\". The scale -1 causes overflow.")
failures:
cast::tests::test_cast_decimal_to_numeric_negative_scale
test result: FAILED. 304 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
error: test failed, to rerun pass `-p arrow-cast --lib`Would be nice if we can make this work.
Describe alternatives you've considered
Additional context
Related code section
arrow-rs/arrow-cast/src/cast/decimal.rs
Lines 819 to 825 in 1db1a88
| let div: D::Native = base.pow_checked(scale as u32).map_err(|_| { | |
| ArrowError::CastError(format!( | |
| "Cannot cast to {:?}. The scale {} causes overflow.", | |
| D::PREFIX, | |
| scale, | |
| )) | |
| })?; |
Metadata
Metadata
Assignees
Labels
enhancementNew feature/addition
Activity
Support casting negative scale decimals to numeric (#9207)