Jefffrey opened a new issue, #8382:
URL: https://github.com/apache/arrow-rs/issues/8382

   **Describe the bug**
   <!--
   A clear and concise description of what the bug is.
   -->
   
   When validating a value for decimal, if error occurs the error message is 
formatted with the invalid value & highest/lowest allowed value; however this 
error message displays the values without accounting for scale, leading to a 
confusing error message.
   
   **To Reproduce**
   <!--
   Steps to reproduce the behavior:
   -->
   
   Example test (e.g. in `arrow-cast/src/cast/mod.rs`):
   
   ```rust
       #[test]
       fn test_123() {
           let array = Int64Array::from(vec![1]);
           dbg!(cast_with_options(
               &array,
               &DataType::Decimal32(1, 1),
               &CastOptions {
                   safe: false,
                   format_options: FormatOptions::default(),
               },
           ));
       }
   ```
   
   Shows error message:
   
   ```
   InvalidArgumentError("10 is too large to store in a Decimal32 of precision 
1. Max is 9")
   ```
   
   **Expected behavior**
   <!--
   A clear and concise description of what you expected to happen.
   -->
   
   Error message should be more like:
   
   > 1.0 is too large to store in a Decimal32 of precision 1. Max is 0.9
   
   - Perhaps add scale to the message too?
   
   **Additional context**
   <!--
   Add any other context about the problem here.
   -->
   
   Original DataFusion issue: https://github.com/apache/datafusion/issues/3666
   
   Relevant code snippet in arrow-rs:
   
   
https://github.com/apache/arrow-rs/blob/1f77ac51c760108ec6263c30666d6581955da336/arrow-data/src/decimal.rs#L1024-L1043
   
   - And same for all other decimal types


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

Reply via email to