Repository: jorgecarleitao/arrow2
Pull request #353 (2021-08-28 06:10:10)

Reduced dependencies within `num`
`num` is a "metacrate" with 5 crates, but we only use `num-traits`. This PR migrates from one to the other.

codecov[bot]: # [Codecov](https://codecov.io/gh/jorgecarleitao/arrow2/pull/353?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao) Report
> Merging [#353](https://codecov.io/gh/jorgecarleitao/arrow2/pull/353?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao) (a3f1391) into [main](https://codecov.io/gh/jorgecarleitao/arrow2/commit/87aa617a0301070f1ecc3fa56e2ff846f7d4c504?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao) (87aa617) will **decrease** coverage by `0.05%`.
> The diff coverage is `83.33%`.

[![Impacted file tree graph](https://codecov.io/gh/jorgecarleitao/arrow2/pull/353/graphs/tree.svg?width=650&height=150&src=pr&token=AgyTF60R3D&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao)](https://codecov.io/gh/jorgecarleitao/arrow2/pull/353?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao)

```diff
@@            Coverage Diff             @@
##             main     #353      +/-   ##
==========================================
- Coverage   81.01%   80.96%   -0.06%     
==========================================
  Files         326      326              
  Lines       21172    21110      -62     
==========================================
- Hits        17152    17091      -61     
+ Misses       4020     4019       -1     
```


| [Impacted Files](https://codecov.io/gh/jorgecarleitao/arrow2/pull/353?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao) | Coverage Δ | |
|---|---|---|
| [src/array/dictionary/mod.rs](https://codecov.io/gh/jorgecarleitao/arrow2/pull/353/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao#diff-c3JjL2FycmF5L2RpY3Rpb25hcnkvbW9kLnJz) | `72.50% <ø> (ø)` | |
| [src/array/specification.rs](https://codecov.io/gh/jorgecarleitao/arrow2/pull/353/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao#diff-c3JjL2FycmF5L3NwZWNpZmljYXRpb24ucnM=) | `70.00% <ø> (ø)` | |
| [src/compute/arithmetics/basic/add.rs](https://codecov.io/gh/jorgecarleitao/arrow2/pull/353/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao#diff-c3JjL2NvbXB1dGUvYXJpdGhtZXRpY3MvYmFzaWMvYWRkLnJz) | `94.83% <ø> (ø)` | |
| [src/compute/arithmetics/basic/div.rs](https://codecov.io/gh/jorgecarleitao/arrow2/pull/353/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao#diff-c3JjL2NvbXB1dGUvYXJpdGhtZXRpY3MvYmFzaWMvZGl2LnJz) | `96.52% <ø> (ø)` | |
| [src/compute/arithmetics/basic/mul.rs](https://codecov.io/gh/jorgecarleitao/arrow2/pull/353/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao#diff-c3JjL2NvbXB1dGUvYXJpdGhtZXRpY3MvYmFzaWMvbXVsLnJz) | `94.83% <ø> (ø)` | |
| [src/compute/arithmetics/basic/pow.rs](https://codecov.io/gh/jorgecarleitao/arrow2/pull/353/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao#diff-c3JjL2NvbXB1dGUvYXJpdGhtZXRpY3MvYmFzaWMvcG93LnJz) | `100.00% <ø> (ø)` | |
| [src/compute/arithmetics/basic/rem.rs](https://codecov.io/gh/jorgecarleitao/arrow2/pull/353/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao#diff-c3JjL2NvbXB1dGUvYXJpdGhtZXRpY3MvYmFzaWMvcmVtLnJz) | `96.52% <ø> (ø)` | |
| [src/compute/arithmetics/basic/sub.rs](https://codecov.io/gh/jorgecarleitao/arrow2/pull/353/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao#diff-c3JjL2NvbXB1dGUvYXJpdGhtZXRpY3MvYmFzaWMvc3ViLnJz) | `94.83% <ø> (ø)` | |
| [src/compute/arithmetics/mod.rs](https://codecov.io/gh/jorgecarleitao/arrow2/pull/353/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao#diff-c3JjL2NvbXB1dGUvYXJpdGhtZXRpY3MvbW9kLnJz) | `51.12% <ø> (ø)` | |
| [src/compute/arithmetics/time.rs](https://codecov.io/gh/jorgecarleitao/arrow2/pull/353/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao#diff-c3JjL2NvbXB1dGUvYXJpdGhtZXRpY3MvdGltZS5ycw==) | `97.48% <ø> (ø)` | |
| ... and [13 more](https://codecov.io/gh/jorgecarleitao/arrow2/pull/353/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/jorgecarleitao/arrow2/pull/353?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/jorgecarleitao/arrow2/pull/353?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao). Last update [87aa617...a3f1391](https://codecov.io/gh/jorgecarleitao/arrow2/pull/353?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Jorge+Leitao).


Patch:
diff --git a/Cargo.toml b/Cargo.toml
index ad96f42e54..94a058e790 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,7 +15,7 @@ name = "arrow2"
 bench = false
 
 [dependencies]
-num = "^0.4"
+num-traits = "0.2"
 chrono = "^0.4"
 # To efficiently cast numbers to strings
 lexical-core = { version = "0.7", optional = true }
diff --git a/benches/arithmetic_kernels.rs b/benches/arithmetic_kernels.rs
index f2ef5a9450..0faa06ff38 100644
--- a/benches/arithmetic_kernels.rs
+++ b/benches/arithmetic_kernels.rs
@@ -24,7 +24,7 @@ use arrow2::util::bench_util::*;
 use arrow2::{
     compute::arithmetics::basic::div::div_scalar, datatypes::DataType, types::NativeType,
 };
-use num::NumCast;
+use num_traits::NumCast;
 use std::ops::Div;
 
 fn bench_div_scalar<T>(lhs: &PrimitiveArray<T>, rhs: &T)
diff --git a/src/array/dictionary/mod.rs b/src/array/dictionary/mod.rs
index 1d911a440b..beb4960fff 100644
--- a/src/array/dictionary/mod.rs
+++ b/src/array/dictionary/mod.rs
@@ -16,7 +16,10 @@ pub use mutable::*;
 use super::{new_empty_array, primitive::PrimitiveArray, Array};
 
 /// Trait denoting [`NativeType`]s that can be used as keys of a dictionary.
-pub trait DictionaryKey: NativeType + NaturalDataType + num::NumCast + num::FromPrimitive {}
+pub trait DictionaryKey:
+    NativeType + NaturalDataType + num_traits::NumCast + num_traits::FromPrimitive
+{
+}
 
 impl DictionaryKey for i8 {}
 impl DictionaryKey for i16 {}
diff --git a/src/array/specification.rs b/src/array/specification.rs
index e0a09757a5..00c69cbd97 100644
--- a/src/array/specification.rs
+++ b/src/array/specification.rs
@@ -1,6 +1,6 @@
 use std::convert::TryFrom;
 
-use num::Num;
+use num_traits::Num;
 
 use crate::types::Index;
 
@@ -8,7 +8,7 @@ use crate::types::Index;
 /// This trait is only implemented for `i32` and `i64`, the two sizes part of the specification.
 /// # Safety
 /// Do not implement.
-pub unsafe trait Offset: Index + Num + Ord + num::CheckedAdd {
+pub unsafe trait Offset: Index + Num + Ord + num_traits::CheckedAdd {
     fn is_large() -> bool;
 
     fn to_isize(&self) -> isize;
diff --git a/src/compute/arithmetics/basic/add.rs b/src/compute/arithmetics/basic/add.rs
index f6b89fd889..e2e0d8ebb5 100644
--- a/src/compute/arithmetics/basic/add.rs
+++ b/src/compute/arithmetics/basic/add.rs
@@ -1,10 +1,7 @@
 //! Definition of basic add operations with primitive arrays
 use std::ops::Add;
 
-use num::{
-    traits::{ops::overflowing::OverflowingAdd, SaturatingAdd},
-    CheckedAdd, Zero,
-};
+use num_traits::{ops::overflowing::OverflowingAdd, CheckedAdd, SaturatingAdd, Zero};
 
 use crate::{
     array::{Array, PrimitiveArray},
diff --git a/src/compute/arithmetics/basic/div.rs b/src/compute/arithmetics/basic/div.rs
index 8e83bb1953..e39fd65011 100644
--- a/src/compute/arithmetics/basic/div.rs
+++ b/src/compute/arithmetics/basic/div.rs
@@ -1,7 +1,7 @@
 //! Definition of basic div operations with primitive arrays
 use std::ops::Div;
 
-use num::{CheckedDiv, NumCast, Zero};
+use num_traits::{CheckedDiv, NumCast, Zero};
 
 use crate::datatypes::DataType;
 use crate::{
diff --git a/src/compute/arithmetics/basic/mul.rs b/src/compute/arithmetics/basic/mul.rs
index 6038bc6f82..f804345c84 100644
--- a/src/compute/arithmetics/basic/mul.rs
+++ b/src/compute/arithmetics/basic/mul.rs
@@ -1,10 +1,7 @@
 //! Definition of basic mul operations with primitive arrays
 use std::ops::Mul;
 
-use num::{
-    traits::{ops::overflowing::OverflowingMul, SaturatingMul},
-    CheckedMul, Zero,
-};
+use num_traits::{ops::overflowing::OverflowingMul, CheckedMul, SaturatingMul, Zero};
 
 use crate::{
     array::{Array, PrimitiveArray},
diff --git a/src/compute/arithmetics/basic/pow.rs b/src/compute/arithmetics/basic/pow.rs
index 017f4515ab..78157ef81e 100644
--- a/src/compute/arithmetics/basic/pow.rs
+++ b/src/compute/arithmetics/basic/pow.rs
@@ -1,5 +1,5 @@
 //! Definition of basic pow operations with primitive arrays
-use num::{checked_pow, traits::Pow, CheckedMul, One, Zero};
+use num_traits::{checked_pow, CheckedMul, One, Pow, Zero};
 
 use crate::{
     array::{Array, PrimitiveArray},
diff --git a/src/compute/arithmetics/basic/rem.rs b/src/compute/arithmetics/basic/rem.rs
index 68f2088a75..af696de496 100644
--- a/src/compute/arithmetics/basic/rem.rs
+++ b/src/compute/arithmetics/basic/rem.rs
@@ -1,6 +1,6 @@
 use std::ops::Rem;
 
-use num::{traits::CheckedRem, NumCast, Zero};
+use num_traits::{CheckedRem, NumCast, Zero};
 
 use crate::datatypes::DataType;
 use crate::{
diff --git a/src/compute/arithmetics/basic/sub.rs b/src/compute/arithmetics/basic/sub.rs
index fd812c9cb9..ffd0b79015 100644
--- a/src/compute/arithmetics/basic/sub.rs
+++ b/src/compute/arithmetics/basic/sub.rs
@@ -1,10 +1,7 @@
 //! Definition of basic sub operations with primitive arrays
 use std::ops::Sub;
 
-use num::{
-    traits::{ops::overflowing::OverflowingSub, SaturatingSub},
-    CheckedSub, Zero,
-};
+use num_traits::{ops::overflowing::OverflowingSub, CheckedSub, SaturatingSub, Zero};
 
 use crate::{
     array::{Array, PrimitiveArray},
diff --git a/src/compute/arithmetics/mod.rs b/src/compute/arithmetics/mod.rs
index c22ff7428d..3414634dfc 100644
--- a/src/compute/arithmetics/mod.rs
+++ b/src/compute/arithmetics/mod.rs
@@ -61,7 +61,7 @@ pub mod time;
 
 use std::ops::{Add, Div, Mul, Neg, Rem, Sub};
 
-use num::{NumCast, Zero};
+use num_traits::{NumCast, Zero};
 
 use crate::datatypes::{DataType, TimeUnit};
 use crate::error::{ArrowError, Result};
diff --git a/src/compute/arithmetics/time.rs b/src/compute/arithmetics/time.rs
index cc6a0579c8..07e979eaf7 100644
--- a/src/compute/arithmetics/time.rs
+++ b/src/compute/arithmetics/time.rs
@@ -11,7 +11,7 @@
 
 use std::ops::{Add, Sub};
 
-use num::cast::AsPrimitive;
+use num_traits::AsPrimitive;
 
 use crate::{
     array::{Array, PrimitiveArray},
diff --git a/src/compute/arity.rs b/src/compute/arity.rs
index e69d8162a2..c48058c81e 100644
--- a/src/compute/arity.rs
+++ b/src/compute/arity.rs
@@ -1,18 +1,13 @@
 //! Defines kernels suitable to perform operations to primitive arrays.
 
-use num::Zero;
-
 use super::utils::combine_validities;
-use crate::{
-    bitmap::{Bitmap, MutableBitmap},
-    error::{ArrowError, Result},
-};
-
-use crate::buffer::Buffer;
-use crate::types::NativeType;
 use crate::{
     array::{Array, PrimitiveArray},
+    bitmap::{Bitmap, MutableBitmap},
+    buffer::Buffer,
     datatypes::DataType,
+    error::{ArrowError, Result},
+    types::NativeType,
 };
 
 /// Applies an unary and infallible function to a primitive array. This is the
@@ -97,7 +92,7 @@ pub fn unary_checked<I, F, O>(
 ) -> PrimitiveArray<O>
 where
     I: NativeType,
-    O: NativeType + Zero,
+    O: NativeType,
     F: Fn(I) -> Option<O>,
 {
     let mut mut_bitmap = MutableBitmap::with_capacity(array.len());
@@ -109,7 +104,7 @@ where
         }
         None => {
             mut_bitmap.push(false);
-            O::zero()
+            O::default()
         }
     });
 
@@ -247,7 +242,7 @@ pub fn binary_checked<T, D, F>(
     op: F,
 ) -> Result<PrimitiveArray<T>>
 where
-    T: NativeType + Zero,
+    T: NativeType,
     D: NativeType,
     F: Fn(T, D) -> Option<T>,
 {
@@ -270,7 +265,7 @@ where
             }
             None => {
                 mut_bitmap.push(false);
-                T::zero()
+                T::default()
             }
         });
 
diff --git a/src/compute/cast/boolean_to.rs b/src/compute/cast/boolean_to.rs
index 47a34dc0c0..2d6c243705 100644
--- a/src/compute/cast/boolean_to.rs
+++ b/src/compute/cast/boolean_to.rs
@@ -10,7 +10,7 @@ use crate::{
 
 pub(super) fn boolean_to_primitive_dyn<T>(array: &dyn Array) -> Result<Box<dyn Array>>
 where
-    T: NativeType + NaturalDataType + num::One,
+    T: NativeType + NaturalDataType + num_traits::One,
 {
     let array = array.as_any().downcast_ref().unwrap();
     Ok(Box::new(boolean_to_primitive::<T>(array)))
@@ -19,7 +19,7 @@ where
 /// Casts the [`BooleanArray`] to a [`PrimitiveArray`].
 pub fn boolean_to_primitive<T>(from: &BooleanArray) -> PrimitiveArray<T>
 where
-    T: NativeType + NaturalDataType + num::One,
+    T: NativeType + NaturalDataType + num_traits::One,
 {
     let iter = from
         .values()
diff --git a/src/compute/cast/dictionary_to.rs b/src/compute/cast/dictionary_to.rs
index eb90610cc7..7b149a3906 100644
--- a/src/compute/cast/dictionary_to.rs
+++ b/src/compute/cast/dictionary_to.rs
@@ -78,7 +78,7 @@ pub fn wrapping_dictionary_to_dictionary_keys<K1, K2>(
     from: &DictionaryArray<K1>,
 ) -> Result<DictionaryArray<K2>>
 where
-    K1: DictionaryKey + num::traits::AsPrimitive<K2>,
+    K1: DictionaryKey + num_traits::AsPrimitive<K2>,
     K2: DictionaryKey,
 {
     let keys = from.keys();
diff --git a/src/compute/cast/primitive_to.rs b/src/compute/cast/primitive_to.rs
index 6b6bb90f3f..dcab568330 100644
--- a/src/compute/cast/primitive_to.rs
+++ b/src/compute/cast/primitive_to.rs
@@ -53,8 +53,8 @@ pub(super) fn primitive_to_primitive_dyn<I, O>(
     options: CastOptions,
 ) -> Result<Box<dyn Array>>
 where
-    I: NativeType + num::NumCast + num::traits::AsPrimitive<O>,
-    O: NativeType + num::NumCast,
+    I: NativeType + num_traits::NumCast + num_traits::AsPrimitive<O>,
+    O: NativeType + num_traits::NumCast,
 {
     let from = from.as_any().downcast_ref::<PrimitiveArray<I>>().unwrap();
     if options.wrapped {
@@ -70,12 +70,12 @@ pub fn primitive_to_primitive<I, O>(
     to_type: &DataType,
 ) -> PrimitiveArray<O>
 where
-    I: NativeType + num::NumCast,
-    O: NativeType + num::NumCast,
+    I: NativeType + num_traits::NumCast,
+    O: NativeType + num_traits::NumCast,
 {
     let iter = from
         .iter()
-        .map(|v| v.and_then(|x| num::cast::cast::<I, O>(*x)));
+        .map(|v| v.and_then(|x| num_traits::cast::cast::<I, O>(*x)));
     PrimitiveArray::<O>::from_trusted_len_iter(iter).to(to_type.clone())
 }
 
@@ -86,10 +86,10 @@ pub fn primitive_as_primitive<I, O>(
     to_type: &DataType,
 ) -> PrimitiveArray<O>
 where
-    I: NativeType + num::traits::AsPrimitive<O>,
+    I: NativeType + num_traits::AsPrimitive<O>,
     O: NativeType,
 {
-    unary(from, num::traits::AsPrimitive::<O>::as_, to_type.clone())
+    unary(from, num_traits::AsPrimitive::<O>::as_, to_type.clone())
 }
 
 /// Cast [`PrimitiveArray`] to a [`PrimitiveArray`] of the same physical type.
diff --git a/src/compute/window.rs b/src/compute/window.rs
index 27be63b3c7..9b8e47ef03 100644
--- a/src/compute/window.rs
+++ b/src/compute/window.rs
@@ -18,7 +18,7 @@
 //! Defines windowing functions, like `shift`ing
 
 use crate::compute::concat;
-use num::{abs, clamp};
+use num_traits::{abs, clamp};
 
 use crate::{
     array::{new_null_array, Array},
diff --git a/src/io/json/read/deserialize.rs b/src/io/json/read/deserialize.rs
index f06b51b713..fb9e56ef1f 100644
--- a/src/io/json/read/deserialize.rs
+++ b/src/io/json/read/deserialize.rs
@@ -20,7 +20,7 @@ use std::{collections::hash_map::DefaultHasher, sync::Arc};
 
 use hash_hasher::HashedMap;
 use indexmap::map::IndexMap as HashMap;
-use num::NumCast;
+use num_traits::NumCast;
 use serde_json::Value;
 
 use crate::types::NaturalDataType;
@@ -80,8 +80,8 @@ fn read_int<T: NativeType + NaturalDataType + NumCast>(
     data_type: DataType,
 ) -> PrimitiveArray<T> {
     let iter = rows.iter().map(|row| match row {
-        Value::Number(number) => number.as_i64().and_then(num::cast::cast::<i64, T>),
-        Value::Bool(number) => num::cast::cast::<i32, T>(*number as i32),
+        Value::Number(number) => number.as_i64().and_then(num_traits::cast::<i64, T>),
+        Value::Bool(number) => num_traits::cast::<i32, T>(*number as i32),
         _ => None,
     });
     PrimitiveArray::from_trusted_len_iter(iter).to(data_type)
@@ -92,8 +92,8 @@ fn read_float<T: NativeType + NaturalDataType + NumCast>(
     data_type: DataType,
 ) -> PrimitiveArray<T> {
     let iter = rows.iter().map(|row| match row {
-        Value::Number(number) => number.as_f64().and_then(num::cast::cast::<f64, T>),
-        Value::Bool(number) => num::cast::cast::<i32, T>(*number as i32),
+        Value::Number(number) => number.as_f64().and_then(num_traits::cast::<f64, T>),
+        Value::Bool(number) => num_traits::cast::<i32, T>(*number as i32),
         _ => None,
     });
     PrimitiveArray::from_trusted_len_iter(iter).to(data_type)
diff --git a/src/io/json_integration/read.rs b/src/io/json_integration/read.rs
index cbdcefe7a1..188aa6f412 100644
--- a/src/io/json_integration/read.rs
+++ b/src/io/json_integration/read.rs
@@ -17,7 +17,7 @@
 
 use std::{collections::HashMap, sync::Arc};
 
-use num::NumCast;
+use num_traits::NumCast;
 use serde_json::Value;
 
 use crate::{
@@ -119,7 +119,7 @@ fn to_primitive<T: NativeType + NumCast>(
             .as_ref()
             .unwrap()
             .iter()
-            .map(|value| value.as_f64().and_then(num::cast::cast::<f64, T>).unwrap())
+            .map(|value| value.as_f64().and_then(num_traits::cast::<f64, T>).unwrap())
             .collect()
     } else {
         json_col
@@ -128,11 +128,11 @@ fn to_primitive<T: NativeType + NumCast>(
             .unwrap()
             .iter()
             .map(|value| match value {
-                Value::Number(x) => x.as_i64().and_then(num::cast::cast::<i64, T>).unwrap(),
+                Value::Number(x) => x.as_i64().and_then(num_traits::cast::<i64, T>).unwrap(),
                 Value::String(x) => x
                     .parse::<i64>()
                     .ok()
-                    .and_then(num::cast::cast::<i64, T>)
+                    .and_then(num_traits::cast::<i64, T>)
                     .unwrap(),
                 _ => {
                     panic!()
@@ -324,7 +324,7 @@ pub fn to_array(
                     x.iter()
                         .map(|value| match value {
                             Value::Number(x) => {
-                                x.as_i64().and_then(num::cast::cast::<i64, i8>).unwrap()
+                                x.as_i64().and_then(num_traits::cast::<i64, i8>).unwrap()
                             }
                             Value::String(x) => x.parse::<i8>().ok().unwrap(),
                             _ => {
@@ -343,7 +343,7 @@ pub fn to_array(
                         x.iter()
                             .map(|value| match value {
                                 Value::Number(x) => {
-                                    x.as_i64().and_then(num::cast::cast::<i64, i32>).unwrap()
+                                    x.as_i64().and_then(num_traits::cast::<i64, i32>).unwrap()
                                 }
                                 _ => panic!(),
                             })
diff --git a/src/io/parquet/read/statistics/primitive.rs b/src/io/parquet/read/statistics/primitive.rs
index c1b0e8f7af..d669425e50 100644
--- a/src/io/parquet/read/statistics/primitive.rs
+++ b/src/io/parquet/read/statistics/primitive.rs
@@ -26,7 +26,7 @@ impl<T, R> From<(&ParquetPrimitiveStatistics<R>, DataType)> for PrimitiveStatist
 where
     T: NativeType,
     R: ParquetNativeType,
-    R: num::cast::AsPrimitive<T>,
+    R: num_traits::AsPrimitive<T>,
 {
     fn from((stats, data_type): (&ParquetPrimitiveStatistics<R>, DataType)) -> Self {
         Self {
diff --git a/src/io/parquet/write/primitive/basic.rs b/src/io/parquet/write/primitive/basic.rs
index 796df77c08..a86f246c7b 100644
--- a/src/io/parquet/write/primitive/basic.rs
+++ b/src/io/parquet/write/primitive/basic.rs
@@ -19,7 +19,7 @@ pub(crate) fn encode_plain<T, R>(array: &PrimitiveArray<T>, is_optional: bool, b
 where
     T: ArrowNativeType,
     R: NativeType,
-    T: num::cast::AsPrimitive<R>,
+    T: num_traits::AsPrimitive<R>,
 {
     if is_optional {
         // append the non-null values
@@ -46,7 +46,7 @@ pub fn array_to_page<T, R>(
 where
     T: ArrowNativeType,
     R: NativeType,
-    T: num::cast::AsPrimitive<R>,
+    T: num_traits::AsPrimitive<R>,
 {
     let is_optional = is_type_nullable(descriptor.type_());
 
@@ -96,7 +96,7 @@ pub fn build_statistics<T, R>(
 where
     T: ArrowNativeType,
     R: NativeType,
-    T: num::cast::AsPrimitive<R>,
+    T: num_traits::AsPrimitive<R>,
 {
     let statistics = &PrimitiveStatistics::<R> {
         descriptor,
diff --git a/src/io/parquet/write/primitive/nested.rs b/src/io/parquet/write/primitive/nested.rs
index 36ff01a723..43483a8149 100644
--- a/src/io/parquet/write/primitive/nested.rs
+++ b/src/io/parquet/write/primitive/nested.rs
@@ -22,7 +22,7 @@ pub fn array_to_page<T, R, O>(
 where
     T: ArrowNativeType,
     R: NativeType,
-    T: num::cast::AsPrimitive<R>,
+    T: num_traits::AsPrimitive<R>,
     O: Offset,
 {
     let is_optional = is_type_nullable(descriptor.type_());
diff --git a/src/types/index.rs b/src/types/index.rs
index 3a6103f002..110c000bc3 100644
--- a/src/types/index.rs
+++ b/src/types/index.rs
@@ -48,7 +48,7 @@ pub trait Index:
     + NaturalDataType
     + std::ops::AddAssign
     + std::ops::Sub<Output = Self>
-    + num::One
+    + num_traits::One
     + PartialOrd
 {
     fn to_usize(&self) -> usize;


Test patch:
diff --git a/tests/it/compute/cast.rs b/tests/it/compute/cast.rs
index 36ebfde4f9..fa6cf994fd 100644
--- a/tests/it/compute/cast.rs
+++ b/tests/it/compute/cast.rs
@@ -48,92 +48,6 @@ fn u16_as_u8_no_overflow() {
     assert_eq!(values, &[1, 2, 3, 4, 5])
 }
 
-#[test]
-fn float_range_max() {
-    //floats to integers
-    let u: Option<u32> = num::cast(f32::MAX);
-    assert_eq!(u, None);
-    let u: Option<u64> = num::cast(f32::MAX);
-    assert_eq!(u, None);
-
-    let u: Option<i32> = num::cast(f32::MAX);
-    assert_eq!(u, None);
-    let u: Option<i64> = num::cast(f32::MAX);
-    assert_eq!(u, None);
-
-    let u: Option<u32> = num::cast(f64::MAX);
-    assert_eq!(u, None);
-    let u: Option<u64> = num::cast(f64::MAX);
-    assert_eq!(u, None);
-
-    let u: Option<i32> = num::cast(f64::MAX);
-    assert_eq!(u, None);
-    let u: Option<i64> = num::cast(f64::MAX);
-    assert_eq!(u, None);
-
-    //integers to floats
-    let u: Option<f32> = num::cast(u32::MAX);
-    assert!(u.is_some());
-    let u: Option<f64> = num::cast(u32::MAX);
-    assert!(u.is_some());
-
-    let u: Option<f32> = num::cast(i32::MAX);
-    assert!(u.is_some());
-    let u: Option<f64> = num::cast(i32::MAX);
-    assert!(u.is_some());
-
-    let u: Option<f64> = num::cast(i64::MAX);
-    assert!(u.is_some());
-    let u: Option<f64> = num::cast(u64::MAX);
-    assert!(u.is_some());
-
-    let u: Option<f64> = num::cast(f32::MAX);
-    assert!(u.is_some());
-}
-
-#[test]
-fn float_range_min() {
-    //floats to integers
-    let u: Option<u32> = num::cast(f32::MIN);
-    assert_eq!(u, None);
-    let u: Option<u64> = num::cast(f32::MIN);
-    assert_eq!(u, None);
-
-    let u: Option<i32> = num::cast(f32::MIN);
-    assert_eq!(u, None);
-    let u: Option<i64> = num::cast(f32::MIN);
-    assert_eq!(u, None);
-
-    let u: Option<u32> = num::cast(f64::MIN);
-    assert_eq!(u, None);
-    let u: Option<u64> = num::cast(f64::MIN);
-    assert_eq!(u, None);
-
-    let u: Option<i32> = num::cast(f64::MIN);
-    assert_eq!(u, None);
-    let u: Option<i64> = num::cast(f64::MIN);
-    assert_eq!(u, None);
-
-    //integers to floats
-    let u: Option<f32> = num::cast(u32::MIN);
-    assert!(u.is_some());
-    let u: Option<f64> = num::cast(u32::MIN);
-    assert!(u.is_some());
-
-    let u: Option<f32> = num::cast(i32::MIN);
-    assert!(u.is_some());
-    let u: Option<f64> = num::cast(i32::MIN);
-    assert!(u.is_some());
-
-    let u: Option<f64> = num::cast(i64::MIN);
-    assert!(u.is_some());
-    let u: Option<f64> = num::cast(u64::MIN);
-    assert!(u.is_some());
-
-    let u: Option<f64> = num::cast(f32::MIN);
-    assert!(u.is_some());
-}
-
 #[test]
 fn f32_as_u8_overflow() {
     let array = Float32Array::from_slice(&[1.1, 5000.0]);