[GitHub] [arrow-rs] alippai commented on a change in pull request #414: Doctests for DecimalArray.

2021-06-14 Thread GitBox


alippai commented on a change in pull request #414:
URL: https://github.com/apache/arrow-rs/pull/414#discussion_r650495530



##
File path: arrow/src/array/array_binary.rs
##
@@ -613,6 +613,32 @@ impl Array for FixedSizeBinaryArray {
 }
 
 /// A type of `DecimalArray` whose elements are binaries.
+///
+/// # Examples
+///
+/// ```
+///use arrow::array::{ArrayData, Array, DecimalArray};
+///use arrow::buffer::Buffer;
+///use arrow::datatypes::DataType;
+///// let val_8887: [u8; 16] = [192, 219, 180, 17, 2, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0];
+///// let val_neg_8887: [u8; 16] = [64, 36, 75, 238, 255, 255, 255, 255, 
255, 255, 255, 255, 255, 255, 255, 255];
+///let values: [u8; 32] = [
+///192, 219, 180, 17, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 36, 75, 
238, 253,
+///255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+///];
+///let array_data = ArrayData::builder(DataType::Decimal(23, 6))
+///.len(2)
+///.add_buffer(Buffer::from([..]))
+///.build();
+///let decimal_array = DecimalArray::from(array_data);
+///assert_eq!(2, decimal_array.len());
+///assert_eq!(8_887_000_000, decimal_array.value(0));
+///assert_eq!(-8_887_000_000, decimal_array.value(1));
+///assert_eq!(16, decimal_array.value_length());
+///assert_eq!(23, decimal_array.precision());
+///assert_eq!(6, decimal_array.scale());

Review comment:
   @novemberkilo now it's merged, thanks for your patience




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [arrow-rs] alippai commented on a change in pull request #414: Doctests for DecimalArray.

2021-06-06 Thread GitBox


alippai commented on a change in pull request #414:
URL: https://github.com/apache/arrow-rs/pull/414#discussion_r646127829



##
File path: arrow/src/array/array_binary.rs
##
@@ -613,6 +613,32 @@ impl Array for FixedSizeBinaryArray {
 }
 
 /// A type of `DecimalArray` whose elements are binaries.
+///
+/// # Examples
+///
+/// ```
+///use arrow::array::{ArrayData, Array, DecimalArray};
+///use arrow::buffer::Buffer;
+///use arrow::datatypes::DataType;
+///// let val_8887: [u8; 16] = [192, 219, 180, 17, 2, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0];
+///// let val_neg_8887: [u8; 16] = [64, 36, 75, 238, 255, 255, 255, 255, 
255, 255, 255, 255, 255, 255, 255, 255];
+///let values: [u8; 32] = [
+///192, 219, 180, 17, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 36, 75, 
238, 253,
+///255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+///];
+///let array_data = ArrayData::builder(DataType::Decimal(23, 6))
+///.len(2)
+///.add_buffer(Buffer::from([..]))
+///.build();
+///let decimal_array = DecimalArray::from(array_data);
+///assert_eq!(2, decimal_array.len());
+///assert_eq!(8_887_000_000, decimal_array.value(0));
+///assert_eq!(-8_887_000_000, decimal_array.value(1));
+///assert_eq!(16, decimal_array.value_length());
+///assert_eq!(23, decimal_array.precision());
+///assert_eq!(6, decimal_array.scale());

Review comment:
   You'll be able to add `assert_eq!("8887.00", 
decimal_array.value_as_string(0));` when I finish the PR. Also I'd keep the 
`assert_eq!(8_887_000_000, decimal_array.value(0));` example (to show the 
values are i128 values)




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org