tustvold opened a new issue, #3265: URL: https://github.com/apache/arrow-rs/issues/3265
**Describe the bug** <!-- A clear and concise description of what the bug is. --> ``` #[test] fn test_cast_decimal128_to_decimal256_negative() { let input_type = DataType::Decimal128(10, 3); let output_type = DataType::Decimal256(10, 5); assert!(can_cast_types(&input_type, &output_type)); let array = vec![Some(i128::MAX), Some(i128::MIN)]; let input_decimal_array = create_decimal_array(array, 10, 3).unwrap(); let array = Arc::new(input_decimal_array) as ArrayRef; let hundred = i256::from_i128(100); generate_cast_test_case!( &array, Decimal256Array, &output_type, vec![ Some(i256::from_i128(i128::MAX).mul_wrapping(hundred)), Some(i256::from_i128(i128::MIN).mul_wrapping(hundred)) ] ); } ``` Fails with ``` thread 'cast::tests::test_cast_decimal128_to_decimal256_negative' panicked at 'assertion failed: `(left == right)` left: `0`, right: `17014118346046923173168730371588410572700`', arrow-cast/src/cast.rs:7251:9 ``` The issue is that it is not performing the scaling operation in the destination type ``` let iter = array.iter().map(|v| { v.and_then(|v| v.mul_checked(mul).ok().map(i256::from_i128)) }); let casted_array = unsafe { PrimitiveArray::<Decimal256Type>::from_trusted_len_iter(iter) }; casted_array .with_precision_and_scale(*output_precision, *output_scale) .map(|a| Arc::new(a) as ArrayRef) ``` **To Reproduce** <!-- Steps to reproduce the behavior: --> **Expected behavior** <!-- A clear and concise description of what you expected to happen. --> **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: github-unsubscr...@arrow.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org