liukun4515 commented on code in PR #2446: URL: https://github.com/apache/arrow-rs/pull/2446#discussion_r947840765
########## arrow/src/array/array_decimal.rs: ########## @@ -314,26 +298,67 @@ impl Decimal128Array { scale, precision ))); } - - // Ensure that all values are within the requested - // precision. For performance, only check if the precision is - // decreased - if precision < self.precision { - self.validate_decimal_precision(precision)?; - } - let data_type = Self::TYPE_CONSTRUCTOR(self.precision, self.scale); assert_eq!(self.data().data_type(), &data_type); - // safety: self.data is valid DataType::Decimal as checked above - let new_data_type = Self::TYPE_CONSTRUCTOR(precision, scale); + Ok(()) + } + + // validate all the data in the array are valid within the new precision or not + fn validate_data(&self, precision: usize) -> Result<()> { + match BYTE_WIDTH { + 16 => self + .as_any() + .downcast_ref::<Decimal128Array>() + .unwrap() + .validate_decimal_precision(precision), + 32 => self + .as_any() + .downcast_ref::<Decimal256Array>() + .unwrap() + .validate_decimal_precision(precision), Review Comment: some usage of https://github.com/apache/arrow-rs/blob/42e9531072366f9f88d524cb95e75ae9ef4bd1e4/arrow/src/array/data.rs#L329 https://github.com/apache/arrow-rs/blob/42e9531072366f9f88d524cb95e75ae9ef4bd1e4/arrow/src/array/data.rs#L377 https://github.com/apache/arrow-rs/blob/42e9531072366f9f88d524cb95e75ae9ef4bd1e4/arrow/src/array/data.rs#L1037 I will go through the usage, and check if it is necessary or not -- 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 For queries about this service, please contact Infrastructure at: us...@infra.apache.org