liukun4515 commented on code in PR #2357:
URL: https://github.com/apache/arrow-rs/pull/2357#discussion_r940129375


##########
arrow/src/array/array_decimal.rs:
##########
@@ -253,11 +253,15 @@ pub trait BasicDecimalArray<T: BasicDecimal, U: 
From<ArrayData>>:
     /// Returns a Decimal array with the same data as self, with the
     /// specified precision.
     ///
+    /// If make sure that all values in this array are not out of 
ranges/bounds with the specified precision,
+    /// please set `need_validation` to `false, otherwise set to `true`.
+    ///
     /// Returns an Error if:
     /// 1. `precision` is larger than [`Self::MAX_PRECISION`]
     /// 2. `scale` is larger than [`Self::MAX_SCALE`];
     /// 3. `scale` is > `precision`
-    fn with_precision_and_scale(self, precision: usize, scale: usize) -> 
Result<U>
+    /// 4. `need_validation` is `true`, but some values are out of 
ranges/bounds
+    fn with_precision_and_scale(self, precision: usize, scale: usize, 
need_validation: bool) -> Result<U>

Review Comment:
   just precision, because the decimal will to stored as a bigint without 
fractional part and just need to check the bounds/ranges for the max/min for 
the precision.
   The max/min value is determined by precision.
   For example decimal(4,n), the max bigint is `9999` and the min is `-9999`, 
we should do validation for the input decimal or value in the decimal array if 
needed.



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