tustvold commented on code in PR #2041:
URL: https://github.com/apache/arrow-rs/pull/2041#discussion_r919136371
##########
arrow/src/array/array_decimal.rs:
##########
@@ -148,6 +148,32 @@ pub trait BasicDecimalArray<T: BasicDecimal, U:
From<ArrayData>>:
self.value(row).to_string()
}
+ /// Build a decimal array from [`FixedSizeBinaryArray`].
+ ///
+ /// This function does not check the validation of each
+ /// value for performance reason.
+ fn from_fixed_size_binary_array(
+ v: FixedSizeBinaryArray,
+ precision: usize,
+ scale: usize,
+ ) -> U {
+ assert!(
+ v.value_length() == Self::VALUE_LENGTH,
+ "Value length of the array ({}) must equal to the byte width of
the decimal ({})",
+ v.value_length(),
+ Self::VALUE_LENGTH,
+ );
+
Review Comment:
You could use the new APIs for this
```
let builder = v
.into_data()
.into_builder()
.data_type(DataType::Decimal(precision, scale));
Self::from(unsafe { builder.build_unchecked() });
```
Saves some clones and is slightly less verbose
##########
arrow/src/array/array_decimal.rs:
##########
@@ -148,6 +148,32 @@ pub trait BasicDecimalArray<T: BasicDecimal, U:
From<ArrayData>>:
self.value(row).to_string()
}
+ /// Build a decimal array from [`FixedSizeBinaryArray`].
+ ///
+ /// This function does not check the validation of each
+ /// value for performance reason.
Review Comment:
```suggestion
/// NB: This function does not validate that each value is in the
permissible
/// range for a decimal
```
--
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]