You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2021/06/14 13:40:48 UTC

[arrow-rs] branch master updated: Doctests for DecimalArray. (#414)

This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new d41ca5f  Doctests for DecimalArray. (#414)
d41ca5f is described below

commit d41ca5fe20ba90df168c5659627d34f298494ec2
Author: Navin <na...@novemberkilo.com>
AuthorDate: Mon Jun 14 23:40:39 2021 +1000

    Doctests for DecimalArray. (#414)
    
    * Doctests for DecimalArray.
    
    * fixup! Doctests for DecimalArray.
    
    * fixup! fixup! Doctests for DecimalArray.
---
 arrow/src/array/array_binary.rs | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/arrow/src/array/array_binary.rs b/arrow/src/array/array_binary.rs
index 0b374db..014d1bf 100644
--- a/arrow/src/array/array_binary.rs
+++ b/arrow/src/array/array_binary.rs
@@ -613,6 +613,30 @@ impl Array for FixedSizeBinaryArray {
 }
 
 /// A type of `DecimalArray` whose elements are binaries.
+///
+/// # Examples
+///
+/// ```
+///    use arrow::array::{Array, DecimalArray, DecimalBuilder};
+///    use arrow::datatypes::DataType;
+///    let mut builder = DecimalBuilder::new(30, 23, 6);
+///
+///    builder.append_value(8_887_000_000).unwrap();
+///    builder.append_null().unwrap();
+///    builder.append_value(-8_887_000_000).unwrap();
+///    let decimal_array: DecimalArray = builder.finish();
+///
+///    assert_eq!(&DataType::Decimal(23, 6), decimal_array.data_type());
+///    assert_eq!(8_887_000_000, decimal_array.value(0));
+///    assert_eq!("8887.000000", decimal_array.value_as_string(0));
+///    assert_eq!(3, decimal_array.len());
+///    assert_eq!(1, decimal_array.null_count());
+///    assert_eq!(32, decimal_array.value_offset(2));
+///    assert_eq!(16, decimal_array.value_length());
+///    assert_eq!(23, decimal_array.precision());
+///    assert_eq!(6, decimal_array.scale());
+/// ```
+///
 pub struct DecimalArray {
     data: ArrayData,
     value_data: RawPtrBox<u8>,