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


##########
arrow/src/array/array_decimal.rs:
##########
@@ -332,15 +331,30 @@ impl Decimal128Array {
 impl Decimal256Array {
     /// Validates decimal values in this array can be properly interpreted
     /// with the specified precision.
-    pub fn validate_decimal_precision(&self, precision: usize) -> Result<()> {
-        if precision < self.precision {
-            for v in self.iter().flatten() {
-                validate_decimal256_precision(&v.to_big_int(), precision)?;
+    fn validate_decimal_precision(&self, precision: usize) -> Result<()> {

Review Comment:
   > Personally, I prefer this function to be an independent `fn`, but not a 
method of `Decimal256Array`, because
   > 
   
   If this is method is just used to `Decimal256Array`, why we should move it 
out of the `impl`? I am confused about this suggestion.
   Besides, It's a private method.
   If move it out of the `impl Decimal256Array`, how to get the `data` of the 
`Self`?
   
   > 1. DecimalArray has its own precision, providing another `precision` to 
its method is somewhat weird.
   
   `with_precision_and_scale` also provide the `precision` and `scale`, is this 
also weird?
   
   > 2. This method is just for `Decimal256Array`, but not the generic decimal 
array. Moving it out the `impl Decimal256Array` can make the code cleaner.
   
   I feel confused about this reason. The method is only used to 
`Decimal256Array`, why not treat it as private function? 
   
   



##########
arrow/src/array/array_decimal.rs:
##########
@@ -332,15 +331,30 @@ impl Decimal128Array {
 impl Decimal256Array {
     /// Validates decimal values in this array can be properly interpreted
     /// with the specified precision.
-    pub fn validate_decimal_precision(&self, precision: usize) -> Result<()> {
-        if precision < self.precision {
-            for v in self.iter().flatten() {
-                validate_decimal256_precision(&v.to_big_int(), precision)?;
+    fn validate_decimal_precision(&self, precision: usize) -> Result<()> {

Review Comment:
   good catch



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