tustvold commented on code in PR #2865:
URL: https://github.com/apache/arrow-rs/pull/2865#discussion_r995154670


##########
arrow-array/src/array/primitive_array.rs:
##########
@@ -917,67 +916,62 @@ impl<T: DecimalType + ArrowPrimitiveType> 
PrimitiveArray<T> {
         })
     }
 
-    pub fn value_as_string(&self, row: usize) -> Result<String, ArrowError> {
-        let p = self.precision()?;
-        let s = self.scale()?;
-        Ok(Decimal::<T>::new(p, s, &T::to_native(self.value(row))).to_string())
+    /// Returns [`Self::value`] formatted as a string
+    pub fn value_as_string(&self, row: usize) -> String {
+        T::format_decimal(self.value(row), self.precision(), self.scale())
     }
 
-    pub fn precision(&self) -> Result<u8, ArrowError> {
+    /// Returns the decimal precision of this array
+    pub fn precision(&self) -> u8 {

Review Comment:
   These methods can be made infallible as the error case is actually 
unreachable, as of #2835 we consistently verify the data type



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