You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by tu...@apache.org on 2023/06/04 18:26:29 UTC

[arrow-rs] branch master updated: deprecate: as_decimal_array (#4363)

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

tustvold 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 dc18d4f58 deprecate: as_decimal_array (#4363)
dc18d4f58 is described below

commit dc18d4f588695bd9e40e3d5f1c5404718faca770
Author: Igor Izvekov <iz...@gmail.com>
AuthorDate: Sun Jun 4 21:26:24 2023 +0300

    deprecate: as_decimal_array (#4363)
    
    * remove: as_decimal_array
    
    * feat: deprecated
---
 arrow-array/src/cast.rs | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/arrow-array/src/cast.rs b/arrow-array/src/cast.rs
index 21993114e..af7e7d606 100644
--- a/arrow-array/src/cast.rs
+++ b/arrow-array/src/cast.rs
@@ -676,7 +676,12 @@ array_downcast_fn!(as_null_array, NullArray);
 array_downcast_fn!(as_struct_array, StructArray);
 array_downcast_fn!(as_union_array, UnionArray);
 array_downcast_fn!(as_map_array, MapArray);
-array_downcast_fn!(as_decimal_array, Decimal128Array);
+
+/// Force downcast of an Array, such as an ArrayRef to Decimal128Array, panic’ing on failure.
+#[deprecated(note = "please use `as_primitive_array::<Decimal128Type>` instead")]
+pub fn as_decimal_array(arr: &dyn Array) -> &PrimitiveArray<Decimal128Type> {
+    as_primitive_array::<Decimal128Type>(arr)
+}
 
 /// Downcasts a `dyn Array` to a concrete type
 ///
@@ -876,18 +881,6 @@ mod tests {
 
     use super::*;
 
-    #[test]
-    fn test_as_decimal_array_ref() {
-        let array: Decimal128Array = vec![Some(123), None, Some(1111)]
-            .into_iter()
-            .collect::<Decimal128Array>()
-            .with_precision_and_scale(10, 2)
-            .unwrap();
-        assert!(!as_decimal_array(&array).is_empty());
-        let result_decimal = as_decimal_array(&array);
-        assert_eq!(result_decimal, &array);
-    }
-
     #[test]
     fn test_as_primitive_array_ref() {
         let array: Int32Array = vec![1, 2, 3].into_iter().map(Some).collect();