Chiicake opened a new pull request, #9207:
URL: https://github.com/apache/arrow-rs/pull/9207

   # Which issue does this PR close?
   
   - Closes #9201 .
   
   # Rationale for this change
   
   Casting decimals with negative scale to integer types currently errors 
because the scale factor is always applied as a division. Negative scales 
represent powers of ten that should scale the integer value up, so the cast 
should multiply instead.
   
   # What changes are included in this PR?
   
   - Apply the scale factor using multiplication when scale < 0 in 
cast_decimal_to_integer.
   
   # Are these changes tested?
   
   Yes, the test given by issue is passed.
   ```
   // 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)]
           );
       }
   ```
   
   # Are there any user-facing changes?
   
   No.


-- 
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]

Reply via email to