pub fn decimal_to_float<T>(from: &PrimitiveArray<i128>) -> PrimitiveArray<T>
where
    T: NativeType + Float,
    f64: AsPrimitive<T>,
{
    let (_, from_scale) = if let DataType::Decimal(p, s) = from.data_type().to_logical_type() {
        (*p, *s)
    } else {
        panic!("internal error: i128 is always a decimal")
    };

    let div = 10_f64.powi(from_scale as i32);
    let values = from
        .values()
        .iter()
        .map(|x| (*x as f64 / div).as_())
        .collect();

    PrimitiveArray::<T>::from_data(T::PRIMITIVE.into(), values, from.validity().cloned())
}
/// Returns a [`PrimitiveArray<i128>`] with the casted values. Values are `None` on overflow
Returns a [`PrimitiveArray`] with the casted values. Values are `None` on overflow
Returns a [ ` PrimitiveArray ` ] with the casted values . Values are ` None ` on overflow
pub fn decimal_to_float<T>(from: &PrimitiveArray<i128>) -> PrimitiveArray<T>
where
    T: NativeType + Float,
    f64: AsPrimitive<T>,
{
    let (_, from_scale) = if let DataType::Decimal(p, s) = from.data_type().to_logical_type() {
        (*p, *s)
    } else {
        panic!("internal error: i128 is always a decimal")
    };
    let div = 10_f64.powi(from_scale as i32);
    let values = from
        .values()
        .iter()
        .map(|x| (*x as f64 / div).as_())
        .collect();
    PrimitiveArray::<T>::from_data(T::PRIMITIVE.into(), values, from.validity().cloned())
}
pub fn decimal_to_float < T > ( from : & PrimitiveArray < i128 > ) -> PrimitiveArray < T > where T : NativeType + Float , f64 : AsPrimitive < T > , { let ( _ , from_scale ) = if let DataType :: Decimal ( p , s ) = from . data_type ( ) . to_logical_type ( ) { ( * p , * s ) } else { panic ! ( " " ) } ; let div = 10_f64 . powi ( from_scale as i32 ) ; let values = from . values ( ) . iter ( ) . map ( | x | ( * x as f64 / div ) . as_ ( ) ) . collect ( ) ; PrimitiveArray :: < T > :: from_data ( T :: PRIMITIVE . into ( ) , values , from . validity ( ) . cloned ( ) ) }
Returns a [`PrimitiveArray<i128>`] with the casted values.
Returns a [ ` PrimitiveArray<i128 > ` ] with the casted values .
from
&PrimitiveArray<i128>
from
&PrimitiveArray<i128>